tags:

views:

185

answers:

1

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?

A: 

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
Thorsten Dittmar