-1

I am making use the the AppData folder by creating images there and shelling out to Windows (with Process.Start( path-to-image )). This causes the built in photo viewer/editor to start up with the image in question. When I look at the process created for this, it shows the following as the executable:

Microsoft.Windows.Photos_2018.18041.15530.0_x64__8wekyb3d8bbwe

Now, when I edit the photo in the app and try to save it over the existing image file, the photo app says:

Opps!  We couldn't save that one.

However, if I save a copy right next to it with a different name, all is good.

I've made sure that the permissions allow writing on the file, etc.

Note that if I use the Paint 3D app to edit the image, I can overwrite the original file.

My question is: Is there something I am doing wrong, or is there a better place I should be using for app specific data where I want my user to be able to modify the image with the photo app.

Update:

Even when I try to start the "ms-paint:" app (Paint 3D), I can't seen to be able to pass an argument to it.

I am left with starting the "basic" paint app which can't save the image, or starting the paint 3d app which can't take an argument.

Eric Vasilik
  • 362
  • 2
  • 14
  • Are you sure about the rights? For the whole folder? – PepitoSh Jul 10 '18 at 01:46
  • Show a minimal version of the code, where you are saving the file... oh i thought it was a file handle thing, however it 3D paint can save it, then all bets are off.. anyway id double check you dont have a handle to the image somewhere in your code – TheGeneral Jul 10 '18 at 01:47
  • PepitoSH, yes, I verified the permissions for the folder. Note that Paint 3D can write over the image, while the photo app cannot. – Eric Vasilik Jul 10 '18 at 01:56
  • TheGeneral, the code that writes the file is simply creating a FIleStream with Create, then writing the bytes. I also tried simply copying the image to the same location with Window's file browser with the same results. – Eric Vasilik Jul 10 '18 at 01:57
  • Does this still happen when your application is closed? – TheGeneral Jul 10 '18 at 02:02
  • TheGeneral, yes, even when my app is not running. – Eric Vasilik Jul 10 '18 at 02:10
  • Could you try instead of Process.Start(path-to-image) to launch the application directly and put path-to-image in the command arguments? – PepitoSh Jul 10 '18 at 02:20
  • PepitoSH, I originally did that, and Windows spawns the photo app which cannot write the file. – Eric Vasilik Jul 10 '18 at 04:03

1 Answers1

1

So, I have decided that the AppData directory should only be used for data that the app is going to read and write. It should not be used for the purposes of allowing a user to see/edit files there.

So, I now will place images that are meant to be edited by the user into that user's Pictures directory. I use:

Environment.GetFolderPath( Environment.SpecialFolder.MyPictures )

To get that path, and launch the photo editor with:

Process.Start( <path to image> )

Thus, the photo app can write any changes back to that file.

Eric Vasilik
  • 362
  • 2
  • 14