I would like to let a user save a file from my iOS app (Xamarin.Forms) to a computer. Since this seems impossible directly, I'd like to let him save the file on the device, so that he can then connect the device to a computer and copy it. But this seems a problem as well (except for images and videos). I tried checking iCloud, but that looks extremely complicated (and overkill).
So, is there some simple way to do this anyway? If not, is there some simple workaround? (I don't have experience with this; please don't discount any obvious solutions.)
iOS offers iTunes file sharing, How to enable file sharing for my app?
This will show all your files in your apps document directory in iTunes. Allowing a user to add and retrieve files from your app.
Related
Our application writes logs to a file at a folder called UnityEngine.Application.persistentDataPath.
Now on Android we can open the file browser and open the log file. Not so on iOS. Short of Jailbreaking the phone to access all folders
Is there a way to access log file in that folder on iOS?
If not, is there another place where I can create that log file, so that the same is accessible e.g. from the file apps? Would Environment.SpecialFolder.MyDocuments work?
Note I am trying to write the file from C# code within unity environment, and ideally would NOT want to jump into NSLog to do this. Just a plain vanilla FileHelper.AppendAllText(LOG_FILE_NAME, "message"); I seek your help in finding a good value for that LOG_FILE_NAME.
Alternatively, rather than us trying to write the logs in a file, is there something better out there in Unity that works cross platform? Something like an inbuilt log file writer sink?
iOS: Application.persistentDataPath points to /var/mobile/Containers/Data/Application//Documents
You can access the ios containers with xcode.
Open xcode, install the app on the device, then open "Window"->"Devices". You can now click on the gear wheel -> "Download Container.."
Niklas has provided you the answer to #1 which is how to access the file on your iOS device.
If you want to make your files accessible to other apps you should check out the UIFaileSharingEnabled functionality for your app.
https://developer.apple.com/documentation/bundleresources/information_property_list/uifilesharingenabled
I'm very new to Visual Studio 2010. I decided to create a simple WFA with C#.
Everything work fine with Images and Audio playback. My intention is to create a standalone application and send it to my friend as a gift. Problem I facing now is that when I tried to publish the application, the Images / Audio is still using the same location in my PC. So it won't play nor display any images.
Any comment on this or guide for me? I did try search for solution but doesn't seems to have any luck.
This is the code that I used to play Audio :
SoundPlayer ply = new SoundPlayer(#"C:\Users\Liam619\Documents\Visual Studio 2010\Projects\BirthdayApp\BirthdayApp\Resources\BirthdaySong.wav");
If I remove or change the path, the Application will hit error for locating the Audio file.
There may be several solutions to your problem.
a) embed the sound into a resource. As a beginner, resources may be a bit tricky to get it right the first time. But I want to encourage you reading something about it. You'll need resources when you want to translate your first program.
b) create an installer which copies the sound file to the installation directory. Try InnoSetup. If you're a programmer, sooner or later, you'll need to create a Setup anyway. Always worth knowing how to do that.
In that case, you still need the path to the sound file, but if you install your EXE into the same path as the sound file, see getting the application's executable directory.
everything in the database whether images or audio refers to your own server database.you have to send the database too with the app and the correct version .NET framework needs to be installed on the target PC.
Pretty much I must find a way to populate image boxes with the corresponding information to the images, if it's possible in a Windows 8/Metro/Store App. I have a database with all the physical paths of the images which are stored on the local computer e.g: "c:\BookImages\spud.jpg". Now when i pull the information from the database with information about the book, I also take the file path of image("c:\BookImages\spud.jpg"). All i need to now do is to fetch the image and display it in a image box. But i do not how to do this, i have been researching for a while now, and I'm coming to the understanding that i cannot select file's from other than the actual install directory of the windows app. Unless i use a FileOpenPicker, which will be a useless for the user to select the folder which contains the images every time they run the app. If anyone has a solution to my problem please let me know it will be much appreciated.
See If all the directories were given access for a win rt app then it would be a security risk
So some specific folder are available try storing user data in there . After that only File Picker can Help.
Heres the link
Folders for winrt
Its a Microsoft policy so Please design app accordingly. You might needd to set capabilities in the app manifest file for some folders. Please go through it :)
The short answer is to have the user pick the folder once and save the StorageFolder in the Windows.Storage.AccessCache.
The long answer is that all this boils down to having your data store in a place that is programmatically accessible.
One option, as Anobik pointed out, is to use either your appdata folders (where you have open access), or something like the Pictures Library, which you can access given a capability in the manifest. This way you don't need to ask the user.
If you use the file picker to let the user select a folder for the data store, he or she has granted permission to access that folder programmatically, including its contained files.
The important thing is that you have to preserve that permission across sessions, which is the purpose of the AccessCache.
Think of a StorageFolder object (and a StorageFile) as an abstraction for a pathname--you never really want to save pathname strings unless you have inherent programmatic access to that location. This isn't true for stuff from the file picker, so you have to use the AccessCache to essentially save the folder reference and its permissions.
Kraig Brockschmidt
Author, Programming Windows 8 Apps with HTML, CSS, and JavaScript, a free ebook from Microsoft Press (also see second edition preview)
I have a little payments webApp, our customers can install it on their IIS and work with it. They can upload their own logotype.
We are using WyBuild to update this apps, but it replaces all files on the web folder with the new version, so the logotypes are deleted, that's why we placed the customer's files in program files, so the updater can't delete them.
the problem is that I can't load the images from the following path
C:\Program Files\MyApp\ImageFoder\logo.jpg
I don't know how to do it and I'm almost sure that is not possible to load
My web application is on
C:\inetpub\wwwroot\MyApp\
I can't have the images on the webFolder because wyBuild deletes them when I'm trying to update them, I already tried the paths like this: (the don't work)
///file:c:/program files/ .... etc
so, the question is
How can I load an image to an asp:image control using it's windows path ?
You need to configure an IIS Virtual Folder to point to the alternate location where the images are stored.
I wouldn't put them in Program Files, though, a sibling folder in wwwroot would be better.
Remember NTFS permissions are easy to mess up and it's easier to manage them in a single place.
Update - for locally installed, localhost-only sites Alternatively (and this is only a good idea if you have minimal amounts of traffic. NOT for public websites), you can serve files from an arbitrary location using a VirtualPathProvider. It sounds like this 'web app' is installed like a desktop app for some reason? If you want to store user data externally, the user's App Data folder would be appropriate, but ONLY if the web app refuses external connections, and can only be accessed from the machine.
Since you're dealing with images, I'd grab the imageresizing.net library and use the VirtualFolder plugin to serve the files dynamically. It's 200KB more in your project, but you get free dynamic image resizing and/or processing if you need it, and you save a few days making a VirtualPathProvider subclass work (they're a nightmare).
Wouldn't it be better to use isolated storage?
Added: I mean on the users machine, and upload them again if they are not found. This takes away your overhead completely.
I am planning to create a screen saver. Thinking of trying out some WPF as well. Anyways, I am not quite sure how I would organize the screen saver on disk in the file system. I have mainly two related issues that I am very uncertain on how to solve:
Normally an application lives, with all its 3rd party assemblies, static resources, images, etc., in the Program Files folder and is run from there. For example C:\Program Files\MyScreenSaver. But (if I haven't missed something) the executable of a screen saver in windows need to have the scr extension and to live in the system folder, for example C:\Windows\System32. How do you program the screen saver so that it can find the "rest of itself"? Would you use the windows registry? Or creat some sort of config file next to the scr file with the path to the rest? And would you make the scr to just be sort of a launcher of an exe in the application folder? Or would this be a bad idea?
I also want the screen saver to download new content from certain places on the internet. But where do I put it, and how does the screen saver find it? If I have understood correctly, an application is not to create new contents in its application folder, but rather in a user folder. How do I find that folder? Do you build it up from environment variables? And in what specific directory should things like this really be in? For example on Vista I see that you have one folder called C:\ProgramData. You also have C:\Users\username\AppData\Local, C:\Users\username\AppData\LocalLow and C:\Users\username\AppData\Roaming. Have also seen a lot of programs dump stuff in the my documents folder (although I hate programs cluttering up my documents folder, so I will probably try to avoid that :p).
What are some best practices when it comes to these issues of laying out your application in the file system? I am want it to be best and "most correct" for Windows 7, which means it will probably work the same in Vista as well (?), but it would also need to work in XP, since a lot of people are using that still.
I'm still using XP :)
System.Environment.SpecialFolders is what you want for these special locations.
Say,
System.Environment.SpecialFolder.LocalApplicationData
For a screen saver I'd try to put most of it in the .exe (.scr) file. It might make the executable quite big but I think it's worth it.
For the downloaded content use application data folder, or maybe allow user to set the location (put the path in registry). For example if you are downloading images, the user might want to put that in My Pictures folder.
You can put it in the System32 (or SysWOW64) folder, but you can also put it in just the Windows folder, which would prevent x86 vs x64 issues.
You can find some other hard to find, but important information about writing screen savers here:
https://github.com/steveniles/MandelZoom/wiki
(Disclosure: I wrote the above wiki as a companion for the source code of one of my own screen savers.)