本文介绍了如何从网络驱动器检索或查看图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我在网络驱动器上成功上传了图片,但现在我无法从同一条路径查看该图片请帮助我。

当我在应用程序中保存图像时只需给出视图按钮的路径: - '.. / Images / Emp Docs /<%#Eval(Salary_URL)%>'它正常工作,但我可以为网络驱动做什么。





这是上传代码:

protected void btnUpLoad_Click(object sender,EventArgs e)

{

mydt =(DataTable)(ViewState [mydatatable]);

// DataRow myrow = mydt.NewRow();

DataRow myrow = mydt .NewRow();



string filePath = Path.Combine(Z:\\,Emp Docs);



//也尝试下面适用于本地驱动器,但在映射网络驱动器上失败

//字符串filePath = Path.Combine(Environment.CurrentDirectory,@。 .\\..\\dev\\WebRootFolder \\SourceFolder \\ImageFolder);



HttpFileCollection uploadedFiles = Request.Files;



for(int i = 0;我< uploadedFiles.Count; i ++)

{

HttpPostedFile userPostedFile = uploadedFiles [i];



尝试

{

if(userPostedFile.ContentLength> 0)

{

//UploadLabel.Text + =文件# +(i + 1)+

//

;



UploadLabel.Text + = userPostedFile .FileName;





userPostedFile.SaveAs(filePath +\\+

路径。 GetFileName(userPostedFile.FileName));



UploadLabel1.Text + = filePath +\\+

Path.GetFileName( userPostedFile.FileName);

}

}

catch(Exception Ex)

{

UploadLabel.Text + =错误:
+ Ex.Message;

}

}

Hi to all i am successfully uploaded image in network drive but now i unable to view that image from the same path please help me.
when i am save image in application only then just give the path for view button:-'../Images/Emp Docs/<%#Eval("Salary_URL")%>' it is working but whta can i do for network drive.


this is upload Code:
protected void btnUpLoad_Click(object sender, EventArgs e)
{
mydt = (DataTable)(ViewState["mydatatable"]);
//DataRow myrow = mydt.NewRow();
DataRow myrow = mydt.NewRow();

string filePath = Path.Combine("Z:\\", "Emp Docs");

//also tried below which works on local drive, but failed on mapped network drive
//string filePath = Path.Combine(Environment.CurrentDirectory, @"..\\..\\dev\\WebRootFolder\\SourceFolder\\ImageFolder");

HttpFileCollection uploadedFiles = Request.Files;

for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile userPostedFile = uploadedFiles[i];

try
{
if (userPostedFile.ContentLength > 0)
{
//UploadLabel.Text += "File #" + (i + 1) +
// "

";

UploadLabel.Text += userPostedFile.FileName;


userPostedFile.SaveAs(filePath + "\\" +
Path.GetFileName(userPostedFile.FileName));

UploadLabel1.Text += filePath + "\\" +
Path.GetFileName(userPostedFile.FileName);
}
}
catch (Exception Ex)
{
UploadLabel.Text += "Error:
" + Ex.Message;
}
}

推荐答案


这篇关于如何从网络驱动器检索或查看图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 16:13