ASP.NET远程文件访问 [英] ASP.NET remote file Accessing

查看:99
本文介绍了ASP.NET远程文件访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的本地网络上使用远程PC中的文件夹

i已经确保所有权限和远程pc共享文件夹也在web配置中添加代码

identity impersonate =true

但是无论何时我想访问该文件夹,它都会转到C:路径。

如何访问该文件夹

 path =\\HP-PC \\ GetFiles; 
String [] fileNamesWithoutExtention = Directory.GetFiles(@ path,* .jpg)。选择(fileName => Path.GetFileNameWithoutExtension(fileName))。ToArray();



这里PC名称HP-PC

文件夹名称GetFiles

错误:

找不到路径的一部分''C:\ HP-PC \ GetFiles \''。



如果有人帮忙,我会很感激:)

解决方案

问题在于路径变量中定义的转义字符。试试这个:



  string  path =  @  \\HP-PC\GetFiles; 
String [] fileNamesWithoutExtention = Directory.GetFiles(@ path, * .avi)。选择(fileName = > Path.GetFileNameWithoutExtension(fileName))。ToArray();


I want to use a folder in remote pc on my local network
i already ensure all the permission and remote pc share the folder also i add the code on web config
identity impersonate="true"
but whenever i want to access the the folder it gone to the C: path.
How can i access the folder

path = "\\HP-PC\\GetFiles";
String[] fileNamesWithoutExtention = Directory.GetFiles(@path,      "*.jpg").Select(fileName => Path.GetFileNameWithoutExtension(fileName)).ToArray();


Here the PC Name HP-PC
Folder Name GetFiles
Error:

Could not find a part of the path ''C:\HP-PC\GetFiles\''.


I will be thankful if anybody help :)

解决方案

The problem is with the escape characters defined in path variable. Try this:

string path = @"\\HP-PC\GetFiles";
            String[] fileNamesWithoutExtention = Directory.GetFiles(@path, "*.avi").Select(fileName => Path.GetFileNameWithoutExtension(fileName)).ToArray();


这篇关于ASP.NET远程文件访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆