如何在应用程序文件夹中保存文件名 [英] How to save filename in application folder
问题描述
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屋!