c# - Opening a file in windows store app, with default app -
I have 2 functions to save and read files on a Windows Store app project:
Public ASINCC Task GravaFicheiro (string URL, String Nome) {HTTP Client Client = New HTTP Client (); HttpResponseMessage Message = Wait client.GetAsync (url); StorageFuller MyFolder = Windows Storage.Application DETA Current.localfolder; Storage file sample file = myfolder.CreateFileAsync is awaiting (Phon, CreationColisionOption.ReplaceExisting); Byte [] file = awaits the message. Content ReedAbitereasy (); Wait for FileIO.WriteBytesAsync (sampleFile, file); Var file = myfolder.GetFilesAsync (); } Public async Tasks & lt; Archive file & gt; Leficheiro (String Nom) {StorageFolder MyFolder = Windows. Storage. Application dta Current.localfolder; Storage file sample file = myfolder.CreateFileAsync (Phon, CreationColisionOption.OpenIfExists) awaiting; Return sample file; } Now I am trying to get a file and trying to open it with the default app, in this special case I am trying to open a PDF.
public assink zero default launch (string path) {// string file file to launch string p2 in file package. Application Data.Current.LocalFolder.Path + "\\" + Path; Var file = wait. Windows Application MODEL. Package. Present. Place established. Gatefile Async (P2); If (file! = Null) {// Set option to show Picker var option = New Windows.System.LauncherOptions (); the option. DisplayPicture = true; // Recover File Bull Launch Launch = Windows.System.Launcher.LaunchFileAsync (File, Options) await; If (success) {// file launches} else {// file lock failed}} and {// file could not be found}} but when I pass the name of the function in the function I do not get this repository
Additional information: File name, directory name, or volume label syntax is incorrect. (Exception with HRESULT: 0x8007007B)
Can anyone help?
This is the source of the error:
string p2 = windows Storage.ApplicationData.Current.LocalFolder.Path + "\\" + Path; Var file = wait. Windows Application MODEL. Package. Present. Place established. Gatefile Async (P2); You are calling GetFileAsync on a package. Present. Installed location Archive folder , but you are passing it to StorageFile in different locations ( ApplicationData.Current.LocalFolder ) Path to If you want to get a file from LocalFolder , get a reference about it: StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder; StorageFile File = Wait Local. GetFileAsync (path);
Comments
Post a Comment