我处于需要加载从相机/图库中拍摄的图像的状态。
我以这种方式创建目录:
var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var library = Path.Combine(documents, "..", "Library");
var userDirectory = Path.Combine(library, directoryname);
Directory.CreateDirectory(userDirectory);
因此,当我在userdirectory
中保存图片以及该图片的路径时,我无法在重新启动应用后加载它。
您将如何处理此路径问题?
编辑: 以这种方式从相册加载时:
var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var library = Path.Combine(documents, "..", "Library");
var userDirectory = Path.Combine(library, CurrentUser.Username);
var ImageDirectory = Path.Combine(userDirectory, "ImageDirectory");
string imageuuid = Guid.NewGuid().ToString();
string ImageFilename = Path.Combine(ImageDirectory, imageuuid + ".jpg");
之后我检查图像是否存在,我每次都能看到它。 路径是:
/Users/exampleuser/Library/Developer/CoreSimulator/Devices/E84B5B50-BA6C-44C2-A755-3A0E96DE20F8/data/Containers/Data/Application/1B287E75-317B-4671-8A16-97F5EA5E27F5/Documents/../Library/userDirectory/ImageDirectory/63408be0-cc49-495f-bc20-e9d90e240597.jpg
我完全关闭应用并重新启动,图片的路径更改为:
/Users/exampleuser/Library/Developer/CoreSimulator/Devices/E84B5B50-BA6C-44C2-A755-3A0E96DE20F8/data/Containers/Data/Application/7AACA518-20BE-4276-B29F-9059CAB1B957/Library/userDirectory/ImageDirectory/63408be0-cc49-495f-bc20-e9d90e240597
正如您在数据/应用程序后看到的那样,它会发生变化。
选择图像后,我保存路径。但是当我加载它时,它无法找到该图像的路径。