可以连接到UNC路径我正在使用std FILE ACCESS示例,并将一行代码更改为如下所示我添加了所有功能添加.txt作为文件类型UNC路径是所有人的读写路径,并且位于同一台计算机上.但是我一直收到访问被拒绝的错误.有人可以给我提供一个可行的例子吗?这让我发疯,并真的质疑LOB应用程序赢得8开发的全部意义. TIA private async void Initialize() { try { //sampleFile = await Windows.Storage.KnownFolders.DocumentsLibrary.GetFileAsync(filename); string myfile = @"\\ALL387\Temp\testfile.txt"; sampleFile = await Windows.Storage.StorageFile.GetFileFromPathAsync(myfile); } catch (FileNotFoundException) { // sample file doesn't exist so scenario one must be run } catch (Exception e) { var fred = e.Message; } }解决方案我已经解决了这个问题,而我发现最好的方法是创建一个文件夹对象枚举文件夹对象中的文件一次将一个文件复制到本地文件夹,然后访问它们似乎您无法打开文件,但可以将其复制. (这是我最初试图实现的目标)希望这会有所帮助private async void Initialize() { try { var myfldr = await Windows.Storage.StorageFolder.GetFolderFromPathAsync(@"\\ALL387\Temp"); var myfiles = await myfldr.GetFilesAsync(); foreach (StorageFile myfile in myfiles) { StorageFile fileCopy = await myfile.CopyAsync(KnownFolders.DocumentsLibrary, myfile.Name, NameCollisionOption.ReplaceExisting); } var dsd = await Windows.Storage.KnownFolders.PicturesLibrary.GetFilesAsync(); foreach (var file in dsd) { StorageFile sampleFile = await Windows.Storage.StorageFile.GetFileFromPathAsync(file.Path); } } catch (FileNotFoundException) { // sample file doesn't exist so scenario one must be run } catch (Exception e) { var fred = e.Message; } }Has anyone EVER managed to use a windows 8 app to copy files from a unc dir to a local dir ?According to the official documentation hereIt is possible to connect to a UNC pathI am using the std FILE ACCESS sample and have changed one line of code to read as belowI have added all the capabilitiesAdded .txt as a file typeThe UNC path is read write to everyone and is located on the same machine..But I keep getting Access Denied Errors.Can anyone possibly provide me with a working exampleThis is driving me mad and really questioning the whole point of win 8 dev for LOB apps.TIAprivate async void Initialize() { try { //sampleFile = await Windows.Storage.KnownFolders.DocumentsLibrary.GetFileAsync(filename); string myfile = @"\\ALL387\Temp\testfile.txt"; sampleFile = await Windows.Storage.StorageFile.GetFileFromPathAsync(myfile); } catch (FileNotFoundException) { // sample file doesn't exist so scenario one must be run } catch (Exception e) { var fred = e.Message; } } 解决方案 I have sorted this out and the way I found best to do it was to create a folder objectenumnerate over the files in the folder objectcopy the files one at a time to the local folder then access themIt seems that you can't open the files, but you can copy them. ( which was what I was trying to achieve in the first place )Hope this helpsprivate async void Initialize() { try { var myfldr = await Windows.Storage.StorageFolder.GetFolderFromPathAsync(@"\\ALL387\Temp"); var myfiles = await myfldr.GetFilesAsync(); foreach (StorageFile myfile in myfiles) { StorageFile fileCopy = await myfile.CopyAsync(KnownFolders.DocumentsLibrary, myfile.Name, NameCollisionOption.ReplaceExisting); } var dsd = await Windows.Storage.KnownFolders.PicturesLibrary.GetFilesAsync(); foreach (var file in dsd) { StorageFile sampleFile = await Windows.Storage.StorageFile.GetFileFromPathAsync(file.Path); } } catch (FileNotFoundException) { // sample file doesn't exist so scenario one must be run } catch (Exception e) { var fred = e.Message; } } 这篇关于Windows 8 StorageFile.GetFileFromPathAsync使用UNC路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-29 22:25