把已知路径的本地文件(不通过浏览选择),上传到远程服务器
本地电脑没问题,上传到远程服务器就不行, 实在找不到办法了啊。
public void UploadFile()
{
//本地电脑文件路径
FileStream stream = new FileStream(@"C:\Users\li\Desktop\tb.txt", FileMode.Open, FileAccess.Read);
int size = Convert.ToInt32(stream.Length);
Byte[] bytes = new Byte[size];
stream.Read(bytes, 0, size);
stream.Close();
FileStream fos = null;
//上传到远程服务器
string filePath = Server.MapPath("~/DataFile/");
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
string fileName = "111.txt";
fos = new FileStream(filePath + fileName, FileMode.OpenOrCreate, FileAccess.ReadWrite);
fos.Write(bytes, 0, bytes.Length);
fos.Close();
}
...全文
相关推荐
linux采用scp命令拷贝文件到本地,拷贝本地文件到远程服务器的方法
今天小编就为大家分享一篇linux采用scp命令拷贝文件到本地,拷贝本地文件到远程服务器的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
本地文件上传到HDFS
Hadoop HDFS的FileSystemAPI操作文件 将准备好的文件上传到hdfs的user/hadoop/music文件下
文件上传到远程服务器demo
java编写 注释到位.解压导入eclipse中即可使用.分客户端和服务端.一看就懂
Mac本地文件上传到SVN服务器
第一一一一一一篇博客↓ 其实是一个很简单的问题【mac本地项目上传至svn服务器】由于我直接运行svn import报错如下 svn: Could not use external editor to fetch log message; consider setting the $SVN_EDITOR environment variable or using the –message (-m) or –file (-F) optionssvn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR is set, an
Mac本地文件上传到CentOS云服务器方法
Mac本地文件上传到CentOS中,可以使用scp指令可以完成。这篇文章给大家介绍了Mac本地文件上传到CentOS云服务器方法,需要的朋友跟随脚本之家小编一起看看吧


