How to display images in smart device application - c#

I am developing smart device application in C#. I am able to add the images in my application by sharing the folder. I am sharing the folder by doing some setting in the emulator. In the emulator by setting File -> Configure ->shared folder, I am able to retrive the images in my application by using Bitmap(). But I want to diplay these images from my application's folder. In my application I have added one folder by using add -> New Folder. In that I kept my images. But when I add them by using Bitmap I am getting error. I am using the code
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
to get the path of application & I am displaying the path in message box in emulator but is giving path as 'program file/managedappl'.So how to add the images from application's local folder? Is there any way? If there is only one way as I above mentioned then can my application successfully display the images on different mobile devices after deploying the application on them ? Can u provide me the code or link through which I can resolve the above issue?

If you look in the emulator: are the image files copied to the device upon running the application? This is necessary to get things working.
Then, you're using the correct code to determine the location of your program's exe file, however, you of course need to add the name of the folder that contains your images.
Let's say your application's exe resides in \Program Files\managedappl and your pictures reside in a folder pics within the program's folder. Then you determine the image path with:
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase), "pics");
After that you can append the name of an image file.
It is important to configure the image files in Visual Studio so they are copied to the device when running the application. If you look under "My Device" in the emulator (the mobile "Explorer"), you should see the following folder structure:
\Program Files\managedappl
\Program Files\managedappl\pics

Related

How to store a UIImage into iPhone's App Folder with Xamarin iOS?

For android, there will be an application folder exist in File Manager -> Phone Storage -> data-> App Package Name where I can save some images inside and it is very easy to find and view from outside without opening the app. I can easily view the images save inside the folder by browsing through File Manager. However, it seems like iPhone didn't provide such function to let user store images into the Application Folder. I can't even find the similar app like File Manager provided by Android in iPhone. Any iPhone user here? Please tell me the what is the correct path to save image in iPhone and I can view it from outside. Normally, I will set the image path as "storage/emulated/0/data/AppPackageName/AppImage" for android. How about iPhone? Thanks in advance for any help. And the most important is where can I browse through the saved image in iPhone?
Here is a doc about File system access in Xamarin.iOS .
Normally, I will set the image path as "storage/emulated/0/data/AppPackageName/AppImage" for android. How about iPhone?
iOS has sandbox in Application , it's the same as Android with path 'storage/emulated/0/data/AppPackageName/AppImage' . However it can not be detected outside the Application, only exposed inside App .
Your application’s access to the file system (and other resources such as the network and hardware features) is limited for security reasons. This restriction is known as the Application Sandbox. In terms of the file system, your application is limited to creating and deleting files and directories in its home directory.
And the most important is where can I browse through the saved image in iPhone?
If you need to browse the saved file in iPhone , maybe you need Sharing with the Files app .
iOS 11 introduced the Files app - a file browser for iOS that allows the user to see and interact with their files in iCloud and also stored by any application that supports it.
You can refer to above doc to know how to implement it in iOS .I think it's not conveniently to do the same thing as Android in iOS .

clickonce deployment setup , gif image not working after install in a different computer

I am trying to deployment a setup for my WPF c# application. i suppose to do it using clickonce because it allow to auto update when i do any update in my application.
Actually i create a setup for my application. when i install that app in a different computer, it works...when i do some update my app, it automatically detect when program launching and user can install new update and run the app.
But it does not show any gif images when program running. when i install the app in a different computer, it create a desktop shortcut and start menu icon. when i run the program via shortcut or start menu, it does not show any gif images. it work fine without showing gif images.
app installed in
C:\Users\dilan\AppData\Local\Apps\2.0\TA5EZNVO.D56\TY5K2KDD.7B6\rcu_..tion_d1f05f20b6f0835a_0001.0000_d9a8ddd982f2efb7
i went to this location and double click the exe file. then app is running with showing gif images.but it does not update. update only happen when run the app via desktop short cut or start menu.
i tested the app by putting image files in to Images folder , Resources folder...but it does not work..
i think i missed some points when creating setup file. can anyone help me , how to deploy a setup file using clickonce , that app work with gif iamges also.
Here is how XAML looks like:
<Image gif:AnimationBehavior.SourceUri="pack://siteoforigin:,,,/Images/tapcard.gif"
VerticalAlignment="Center" Width="100" Margin="0,0,20,0"/>
I might not have inculded your images in your project.
See this answer. You need to right click the file in Solution Explorer and then Include in project .
When you include them, the Build Action of the image file would be set to Resource - no need to copy images individually (Copy to Output Directory should be by default set to Do not copy).
Let's say you have a WPF project in the folder Images named Progress.gif.
In code behind you reference it like this:
new BitmapImage(new Uri("pack://application:,,,/Images/Progress.gif", UriKind.Absolute))
In XAML you reference the image simply like this
<Image Source="./Images/Progress.gif" >
You can use another URI scheme as well, e. g. pack://siteoforigin:,,,/Images/tapcard.gif refers to an image that is located on the server where the app was deployed.
If you do not want to be bound by the restrictions of having your
application resources declared at compile time, there is another
option for you. No, this doesn't involve using fully qualified Uris to
reference resources over the internet. Although, that is indeed
supported. WPF provides you with an abstraction for the application's
conceptual site of origin i.e. the location from where the application
was deployed. For instance, if your application was launched from
http://nerddawg.blogspot.com, then your application's site of origin
is http://nerddawg.blogspot.com. To access an image at
images/AuntDahlia.gif at that location, you would specify in markup:
<Image Source="pack://siteoforigin:,,,/images/AuntDahlia.jpg" />
So you check in the properties of your WPF project on Publis tab the Publish location or Installation folder URL (if specified). If installation URL is e.g. http://myserver:8080 then you need to verify from the client, that the file http://myserver:8080/Images/tapcard.gif exists by typing this url into a browser. Depending on the folder structure of your web you might need to copy the file manually there.
pack://siteoforigin: means you are getting the resource over the network from the web or file server.

Contents of bin folder after publishing .NET project to an MSI file - where will the image go?

I am working on a WinForms application which uses a flatbed scanner (in conjunction with PixTools library).
Currently when running in debug mode (unpublished), when the application code scans the image, it stores the image file .jpg in the bin folder of the project (C:...\Source\winapp\bin). My code then has to manually move this file using File.Move() to the directory where I want it to end up.
However I am thinking that when I publish the application to install on another machine, this bin folder won't exist. I am wondering where the application is likely to store the .jpg from the scanner in this case so I can write the code in advance. For instance, will the image appear somewhere in the installation folder which is selected when installing application the first time round?
Thanks for any advice/help
C
You can Create/Store your image file(.jpg) into your Debug/Release folder which is the path from where your Application exe runs.
The following code gives you the path from where your Application is running:
String ApplicationFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", "");
The Above code returns the path similar to
SolutionFolder/ProjectFolder/bin/Debug(or)Release
So you can target your code to retrieve the image from the above location as it is avaialable even after deplyoing/Installing the Application on client PC.

To display the images in mobile devices is it necessary that the images should resides on device in smart device application?

I am devloping smart device application in C#. In this application I have some images in my application which I used to dispay on emulator from my application. To display the images on emulator I need to create the one folder of images which resides on the emulator. Only after that I am able to display the images in emulator. I am able to create the folder in emulator by using File->Configure->General->Shared Folder. For sharing the folder I am giving the path of the folder which contains the images. Once I share the folder the folder of images which resides in my application will get copied in emulator with the name "Storage Card". Now I need to use the path as Bitmap bmp=new Bitmap(#"/Storage Card/ImageName.jpg"); Now I am able to display the images in emulator. Can we display the images in the emulator without any image folder which resides on emultor (so that we dont need to place the image folder in emulator as in the above case by sharing the folder) ? If the answere is no then to run the application on different mobile devices we need to place the folder which contains the images on different mobile devices. Isnt it? If the answere is yes then how we can display the images on different mobile device from our application without placing any folder of images on mobile devices?
In order to display the images, you'll need to have the images on the device (or emulator) - otherwise it wouldn't have the data to know what to display.
There are a few ways you can get the images to the device or emulator. The easiest is if you add the images to your Visual Studio project and mark the image files as content that should be copied to the destination folder. Then Visual Studio will copy the image files along with the application file when you go to debug it, which is probably what you want. You'll need to change the path your application is looking for the files in (since they won't be in "/Storage Card" anymore).
To get the images on a target (non-emulator) device, you'll probably want to create a Visual Studio Install project, and have it include your exe and the image files (and specify which folder to put the images in when the app is installed).
The above is what I've done, and would recommend. But there are other options. One might be to download the images from the web, which might work for both an emulator and devices (but will require you to have the images available on the web, and the emulator and devices to be connected).

How do I add files to a windows mobile device when deploying it?

I have a number of images and a CSV data file that I want to deploy to a windows mobile device along with my application. I'm using Visual Studio 2008 and C#.
I've added a "Content" folder to my project which contains the bmp images and the CSV file. When running my program on the emulator (by hitting F5) only the app is deployed, and not the "Content" directory.
I know I can add images to the resource file, but that isn't what I want to do - I want the images to actually be available on the device so that they can be changed without having to deploy a new application.
So my question is how can I set it up so that the "Content" directory is copied to the device?
Thanks in advance!
THe files from a "Content" folder will not be deployed on your device.
In order to deploy a file, right click it -> Properties -> select "Content" from Build Action
Are the files within that folder also marked as content?
In order to deploy files in the content folder along with folder,
Follow the below procedure,
Right Click the files inside Content folder--> select Propeties-->Build Action-->set build action as "Content" --> Copy to output directory--> set Copy always or Copy if newer.
Like this Do changes to all type of files(.csv,bmp etc)
Then Finally deploy into emulator or native device.
You will see the all files appearing on the program directory of emulator or device.
Happy Coding -:)

Categories