如何在应用程序文件夹中保存文件名 [英] How to save filename in application folder

查看:118
本文介绍了如何在应用程序文件夹中保存文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public string Addgrievance(Dictionary< string,string> attributes,Dictionary< string,byte []> files)

{

string returnresult =Fail;

试试

{

con.Open();

SqlCommand comm = new SqlCommand();

comm.Connection = con;

comm.CommandType = CommandType.StoredProcedure;

comm.CommandText =MBL_MOB_APP_CMS;

comm.Parameters.AddWithValue(@ Qtype,19);

comm.Parameters.AddWithValue(@ Description,attributes [Description]。ToString());

comm.Parameters.AddWithValue(@ Username,attributes [UserName]。ToString());

comm.Parameters.AddWithValue(@ Status,1);

string filePath =;

foreach(KeyValuePair< string,byt E []>配对文件)

{



filePath = HttpContext.Current.Server.MapPath(string.Format(〜/ AssistanceSchemeFile / {0 },pair.Key));



File.SaveAs(pair.Key);



}



int result = comm.ExecuteNonQuery();



if(result> 0)

{

returnresult =成功;

}



// obj .returnresult = returnresult;

返回returnresult;

}

catch(例外)

{

throw;

}

}



我尝试了什么:



i am在WEB API中使用文件上传和i在Dictionary中获取文件< string,byte []>文件

当我尝试保存在apllication中然后我得到Exeption in-



File.SaveAs(pair.Key); < br $>
'System.IO.File'不包含'SaveAs'的定义

所以请帮助我

如何解决这个问题

解决方案

System.IO.File Class [ ^ ]



FileUpload.SaveAs方法 [ ^ ]

public string Addgrievance(Dictionary<string, string> attributes, Dictionary<string, byte[]> files)
{
string returnresult = "Fail";
try
{
con.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = con;
comm.CommandType = CommandType.StoredProcedure;
comm.CommandText = "MBL_MOB_APP_CMS";
comm.Parameters.AddWithValue("@Qtype", 19);
comm.Parameters.AddWithValue("@Description", attributes["Description"].ToString());
comm.Parameters.AddWithValue("@Username",attributes["UserName"].ToString());
comm.Parameters.AddWithValue("@Status", 1);
string filePath="";
foreach (KeyValuePair<string, byte[]> pair in files)
{

filePath = HttpContext.Current.Server.MapPath(string.Format("~/AssistanceSchemeFile/{0}", pair.Key ));

File.SaveAs(pair.Key);

}

int result = comm.ExecuteNonQuery();

if (result > 0)
{
returnresult = "Success";
}

// obj.returnresult = returnresult;
return returnresult;
}
catch (Exception)
{
throw;
}
}

What I have tried:

i am Using File Upload in WEB API and i Get File in Dictionary<string, byte[]> files
and when i try to save in apllication then i get Exeption in Line-

File.SaveAs(pair.Key);
'System.IO.File' does not contain a definition for 'SaveAs'
so please help me
How to Fix this Issues

解决方案

System.IO.File Class[^]

FileUpload.SaveAs Method[^]


这篇关于如何在应用程序文件夹中保存文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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