Windows 8 StorageFile.GetFileFromPathAsync 使用 UNC 路径 [英] Windows 8 StorageFile.GetFileFromPathAsync Using UNC Path
问题描述
有没有人设法使用 Windows 8 应用程序将文件从 unc 目录复制到本地目录?
这里根据官方文档p>
可以连接到 UNC 路径
我正在使用 std FILE ACCESS 示例,并将一行代码更改为如下所示我添加了所有功能添加 .txt 作为文件类型UNC 路径对每个人都是读写的,并且位于同一台机器上...
但我不断收到拒绝访问错误.
谁能给我一个可行的例子这让我发疯,并且真的质疑 Win 8 dev 的 LOB 应用程序的全部意义.
TIA
私有异步 void Initialize(){尝试{//sampleFile = await Windows.Storage.KnownFolders.DocumentsLibrary.GetFileAsync(filename);字符串 myfile = @"\ALL387Temp estfile.txt";sampleFile = 等待 Windows.Storage.StorageFile.GetFileFromPathAsync(myfile);}捕获(FileNotFoundException){//示例文件不存在,因此必须运行场景一}捕获(异常 e){var fred = e.Message;}}
我已经解决了这个问题,我发现最好的方法是创建一个文件夹对象枚举文件夹对象中的文件一次一个地复制文件到本地文件夹,然后访问它们
您似乎无法打开文件,但您可以复制它们.(这是我最初想要实现的目标)
希望对你有帮助
私有异步 void Initialize(){尝试{var myfldr = 等待 Windows.Storage.StorageFolder.GetFolderFromPathAsync(@"\ALL387Temp");var myfiles = 等待 myfldr.GetFilesAsync();foreach(存储文件 myfile 在 myfiles 中){StorageFile fileCopy = await myfile.CopyAsync(KnownFolders.DocumentsLibrary, myfile.Name, NameCollisionOption.ReplaceExisting);}var dsd = 等待 Windows.Storage.KnownFolders.PicturesLibrary.GetFilesAsync();foreach(dsd 中的 var 文件){StorageFile sampleFile = await Windows.Storage.StorageFile.GetFileFromPathAsync(file.Path);}}捕获(FileNotFoundException){//示例文件不存在,因此必须运行场景一}捕获(异常 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 here
It is possible to connect to a UNC path
I am using the std FILE ACCESS sample and have changed one line of code to read as below I have added all the capabilities Added .txt as a file type The 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 example This is driving me mad and really questioning the whole point of win 8 dev for LOB apps.
TIA
private async void Initialize()
{
try
{
//sampleFile = await Windows.Storage.KnownFolders.DocumentsLibrary.GetFileAsync(filename);
string myfile = @"\ALL387Temp estfile.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 object enumnerate over the files in the folder object copy the files one at a time to the local folder then access them
It 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 helps
private async void Initialize()
{
try
{
var myfldr = await Windows.Storage.StorageFolder.GetFolderFromPathAsync(@"\ALL387Temp");
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 路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!