The filename, directory name, or volume label syntax is incorrect. (Exception from HRESULT: 0x8007007B)

2

I'm receiving this error when the code look for the path, I dont understand whe this happend, I think im doing right.

Code:

 string newUri = ImageGalleryUri.Replace("ms-appdatalocal/", "");  //Replace this part of the string with a nonspace character.
        newUri = newUri.Replace("/", "\\");
        newUri = newUri.Replace("%20", " "); //Replace the ASCII code for space for an actual space. For some reason I'm getting invalid character error with %20.
        StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder;
        StorageFile storageFile = await folder.GetFileAsync(newUri);
        DataPackage dp = new DataPackage();    //Create the DataPackage containing the clipboard content.
        dp.SetBitmap(RandomAccessStreamReference.CreateFromFile(storageFile));
        Clipboard.SetContent(dp);
        await successDialog.ShowAsync();

The error is in this line: newUri = ms-appdata:\local\Books\Assets\Recursos para el docente\Matematicas\9\Esp\1\0\Geometria_Page_04.png

StorageFile storageFile = await folder.GetFileAsync(newUri);
c#
winrt-xaml
asked on Stack Overflow Jun 19, 2014 by user3604503 • edited Jun 19, 2014 by user3604503

2 Answers

1

Maybe try this:

newUri = Uri.EscapeDataString(newUri);

Instead of:

newUri = newUri.Replace("%20", " ");
answered on Stack Overflow Jun 19, 2014 by Pabinator
0
  1. Debug to check the actual value of the string.
  2. Windows + R, then copy the string and see if it opens.
  3. See if all slashes/backslashes are properly escaped (I don't think it's correct to use backslashes here).
  4. Create a file named file.txt and try this:

    using Windows.Storage;

StorageFile file = await StorageFile.GetFileFromApplicationUriAsync("ms-appdata:///local/file.txt");

  1. Try replacing the argument passed in the function above with your string.
answered on Stack Overflow Jun 19, 2014 by andypopa

User contributions licensed under CC BY-SA 3.0