文件从客户端复制到服务器 [英] file copy to server from client

查看:85
本文介绍了文件从客户端复制到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个目录,例如Hostedwebsite,来自该目录的网站正在运行.
我想上传一些文件,这样我就不想保存这些文件.托管下托管文件夹位于C:\ Root.

我想将文件保存在其他路径中说D:UploadedFile//directory
每次上传都会创建一个新的directoy
所以server.mappath将提供C的路径,但是我想在D盘中复制文件..

我使用字符串
获得了路径

Suppose I have one directory, say Hostedwebsite, from this directory web site is running now.
I want to upload some files so that I don''t want to save these file Under hosted Hosted folder reside in C:\Root.

I want to save file in other path say D: UploadedFile//directory
for every upload new directoy will get created
so server.mappath will give the path of C but i want to copy file in D Drive..

I got the path using string

Path = System.IO.Path.Combine(rootPath, test);


但是,当我使用下面的代码从本地系统复制到另一个系统时.


But while I am copying from local system to another system using below code.

File.Copy(attachementList[index].FilePath, Path + "\\\\" + attachementList[index].FileName);


它给IO异常设备未准备好.

你们能给我个主意吗?


It is giving IO exception device not ready.

Can youu guys give me idea?

推荐答案

一个,您需要确保文件夹存在,然后再尝试将其复制到该文件夹​​,第二个,目标路径很可能是不正确,路径分隔符过多.您可能会得到类似d:\ Uploaded File \\\ file.txt之类的内容.您曾经使用过Path.Combine,为什么不再次使用它?
One, you need to make sure the folder exists before trying to copy to it, and two, the destination path is most likely incorrect, too many path delimiters. You are probably getting something like d:\Uploaded File\\\file.txt. YOU used Path.Combine once, why not use it again?


这篇关于文件从客户端复制到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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