I am having a problem getting an SQLite3 database to work with OneDrive. I have no problems running the database from ApplicationData.Current.RoamingFolder, but when I try to add a FolderPicker to allow the user to specify a folder to store the database, I keep getting a CannotOpen error from SQLite.
I am adding a token for the folder to the FutureAccessList like so:
// give us a consent to use the folder
var folderPicker = new FolderPicker();
folderPicker.FileTypeFilter.Add("*");
_currentFolder = await folderPicker.PickSingleFolderAsync();
// after that, we can store the folder for future reuse
var pickedFolderToken = StorageApplicationPermissions.FutureAccessList.Add(_currentFolder);
ApplicationData.Current.LocalSettings.Values.Add("FolderTokenSettingsKey", pickedFolderToken);
As I said, the application runs fine when using RoamingFolder, but I am trying to get the database to be stored on remote storage so I can keep it synchronized between multiple devices.
I initially thought that RoamingFolder would be synchronized across multiple devices (as long as it is the same Microsoft account logged in), but that does not appear to be the case, so I am trying to get it to work with SkyDrive, or some other remote storage service.
The SQLite3 database is configured to create the database if it does not exist, and I have tried both scenarios with the same result - CannotOpen in either case. Anyone know if this is allowed in WinRT 8.1 applications? My other option is to copy the database from to the RoamingFolder and access that copy from the application, and then copy back to when writing to the database.
SQLite works with native Windows filesystem APIs (Win32), but the pickers (like FolderPicker) and the FutureAccessList work only with brokered filesystem APIs (Windows.Storage). There is no way to mix the two at the same time.
But items in your roaming folder should get copied to other devices with the same Microsoft Account, although it isn't instantaneous. How long have you waited to see if it turns up? How big is the file? Did you read this topic and related items on MSDN?
Otherwise, yes your work-around of copying the file from the brokered location into your app's storage, then modifying it, then copying it back again after it has been closed would work.
Related
A roaming user (networked, with admin privileges, Win 10) stated that (A) onedrive syncing over the network is slowing down the winform app, and (B) requested to be able to set a default folder for data access.
Question: firstly, shouldn't the user be asked to work with their IT to find out what folder won't result in any data access issues or onedrive sync issues? For a temp workaround, is there anything wrong with also telling the user to use the roaming folders among the following:
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
and then modify the code to allow users to set a default data folder with a try-catch obviously?
My gut feeling is that the user is getting hung up in ...\OneDrive\MyDocuments which I think is what would be returned by .ApplicationData. Also, just because a user wants to set a default data directory doesn't mean that his enterprise will allow him to go anywhere he wants on a disk of workstation at the office that he remotes into(?)
I'm making an App where I need to create CSV files with data I need to load in a software in a Windows machine. I want to connect an Android Device via USB to a computer and get the file from there. Is there any way I can create a file that's visible for a computer?
From what I've found you can only create cache files and files only visible to the app (neither my PC or the File Manager on the phone can see them).
I thought about creating a service in the network and send the data to that and create the file in the server but that would add more failing points and of course is more work, besides sometimes the app could be running in parts where the Wifi doesn't get to it and would mean I would have to do a temporal file and somehow upload it when it connects back, so not practical at all.
Of course you can create files and folders on external storage of the android device, which is publicly accessible. Refer to this guide.
Note: You need to get permission WRITE_EXTERNAL_STORAGE to write and READ_EXTERNAL_STORAGE to read from device's external storage.
I am using Properties.setting.default.var to permanently store a value in a C# application on the same PC.
Now I am facing a problem that when I save the value but copy the application to another PC, the permanent value does not remain. Does the properties.setting trick not work in this scenario? If yes? Please advise the solution.
You need to get the settings stored in location that is accessible by all devices you plan to run your program on.
You can either
make sure current location of the settings file is synchronized between all devices - this way you can keep your existing code. You can sync files via roaming profiles in Windows Domain, by letting some file share synchronization tool to sync that file - i.e. OneDrive, by just manually copy file or any other way you can find.
write settings file yourself to shared location which can be accessed by all devices - pretty much any service that allow to upload data would do. Some will allow authenticated access so you can limit settings to particular user (OneDrive, GoogleDrive,...), some some form of anonymous/semi-authenticated uploads (which make personalized settings a bit harder and make them public for all to see). You may still be able to use some of the existing code but likely getting your settings in JSON format and uploading would be easier.
Can any one tell me how I can create a folder in local drives through c# code in winrt. I am creating a windows 8 app. I have to create a folder in local drives like in d drive or e drive through my winrt app to save some data in it. I don't want to create folder in local storage.
Can anyone tell me how i can achieve this.
WinRT restricts the filesystem locations that are available to applications.
See this detailed post for additional information: Accessing data and files
Short answer: WinRT restricts the locations that your app can access, and it may not be possible to do what you want.
However, if you are saving data related to your application, what are the reasons for not using local app data?
There is only one way to access file system locations that the app does not have access to. The FileOpenPicker or FolderPicker. Once a user has selected the file and folder for the backup, you can maintain this access for future use by using the Windows.Storage.AccessCache namespace and the appropriate methods. Here is a link to the related answer: Save File or Folder For Later Use .
Best of Luck
Using XAML C# in Windows "Metro" Apps how do I go about playing a certain video file. Examples:
D:\video1.wmv
\\MEDIAPC\video2.wmv
The only way I managed to get this working so far is by using FilePicker, but I don't want to use this as I already have a list of files to play.
I have tried to use GetFileFromPathAsync but I keep getting permission / access issues
await StorageFile.GetFileFromPathAsync(#"D:\video1.wmv");
Apologies if this has been answered I just couldn't find an answer that fits my problem.
If your D:\ drive is a non-network resource try adding the Removable storage application capability. This can be accomplished by double-clicking on the Package.appxmanifest and navigating to the Capabilities tab. By default your application (assuming it is a Windows Store app) only has access to local files packaged with your app or files stored in local/roaming/temp folders (usually reserved for Application state).
If your data is stored on a Network resource that requires authentication you will want to enable the Enterprise Authentication capability.
You may also want to fiddle with the Home and Work Networks for the \MEDIAPC\ files if you aren't accessing resources that require network authentication.
Further Reads:
Accessing data and files
How to load data from files
App Capabilities Overview