[英]Access to local path denied
I'm using Sharefile API and I'm trying to download files from Sharefile but when I do it I get the message:我正在使用 Sharefile API 并且我正在尝试从 Sharefile 下载文件,但是当我这样做时,我收到消息:
Access to path 'C:\\_testing' is denied.
拒绝访问路径“C:\\_testing”。
Here's part of the code to the download method:这是下载方法的部分代码:
Public Sub FileDownload(ByVal fileId As String, ByVal localPath As String)
...
...
Try
Dim target As FileStream = New FileStream(localPath, FileMode.Create, FileAccess.Write)
Dim chunk(8192) As Byte
Dim len As Integer
...
...
...
End Sub
At the line where I define "target" it throws an exception and the message is the one posted above the code sample.在我定义“目标”的那一行,它抛出一个异常,消息是代码示例上方发布的消息。
Why is this?为什么是这样? My test folder has read/write permissions and FileMode is set to "Create".
我的测试文件夹具有读/写权限,并且 FileMode 设置为“创建”。 Also, I've tried in different locations and without any luck.
另外,我在不同的地方尝试过,但没有任何运气。
After many comments, i'll try to post an answer. 经过很多评论后,我将尝试发布答案。
Dim target As FileStream = New FileStream(localPath & fileId, FileMode.Create, FileAccess.Write)
You want to download a FILE, not a FOLDER. 您要下载文件,而不是文件夹。
For instance, 例如,
Dim target As FileStream = New FileStream("C:\Users\Me\Desktop", FileMode.Create, FileAccess.Write)
throws an error, 引发错误,
Dim target As FileStream = New FileStream("C:\Users\Me\Desktop\test.jpg", FileMode.Create, FileAccess.Write)
doesn't. 没有。
i am having this issue too,我也有这个问题
filestream = New FileStream("C:\somefile.txt", FileMode.Create, FileAccess.readWrite, FileSHare.ReadWrite)
the file somefile.txt might exists or not, that is why i selected fileMode.create.文件 somefile.txt 可能存在或不存在,这就是我选择 fileMode.create 的原因。 still having the error.
仍然有错误。 My file is not passed into a parameter, its directly a string.
我的文件没有传递给参数,它直接是一个字符串。 So im still searching what is going on.
所以我还在寻找发生了什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.