System.io.file.readallbytes出错 [英] Error in System.io.file.readallbytes

查看:81
本文介绍了System.io.file.readallbytes出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,任何团体都会解决问题所在,我创建了文件,但代码给出错误FileNotFoundException未处理...







Dear Friends any body would sort out where is the problem, i have created the file but the code give the error FileNotFoundException Was unhandled ...



Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.FtpWebRequest.Create("ftp://ftp.uibonline.com/uibsat/test.txt"), System.Net.FtpWebRequest)
        request.Credentials = New System.Net.NetworkCredential("ksauib@uibonline.com", "123456")
        request.Method = System.Net.WebRequestMethods.Ftp.UploadFile


        Dim file() As Byte = System.IO.File.ReadAllBytes("C:\test.txt")

        Dim strs As System.IO.Stream = request.GetRequestStream()
        strs.Write(file, 0, file.Length)
        MsgBox("File Uploaded", MsgBoxStyle.Information)

        strs.Close()
        strs.Dispose()




    End Sub
End Class

推荐答案

错误消息非常具体:仅针对一个问题生成FileNotFoundException:找不到文件。检查您的路径,并确保文本文件位于根文件夹中 - 这是非常不可能的,因为您需要真正的管理员权限才能写入启动驱动器的根文件夹!
The error message is pretty specific: FileNotFoundException is only generated for one problem: When the file is not found. Check your path, and make sure the text file is in the root folder - which is very highly unlikely, as you need real admin permissions to write to the root folder of your boot drive!


这篇关于System.io.file.readallbytes出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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