2
Answers

File upload. Error of Could not find a part of the path.

Photo of Vinoth Kumar

Vinoth Kumar

7y
450
1
How to Solve This error "System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\Administrator\Documents\Visual Studio 2010\WebSites\atndreport\Document\Book1.csv'."
 
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string filename = FileUpload1.FileName.ToString();
string path = Server.MapPath("~/Document/" + filename);
FileUpload1.PostedFile.SaveAs(path);
FetchData(path);
}
}
protected void FetchData(string filepath)
{
DataTable dt = new DataTable();
bool IsFirstRowHeader = true;
string[] columnf = new string[] { "" };
using (TextFieldParser parser = new TextFieldParser(filepath))
{
parser.TrimWhiteSpace = true;
parser.TextFieldType = FieldType.Delimited;
parser.SetDelimiters(",");
if (IsFirstRowHeader)
{
columnf = parser.ReadFields();
foreach (string sds in columnf)
{
DataColumn year = new DataColumn(sds.Trim().ToLower(), Type.GetType("System.String"));
dt.Columns.Add(year);
}
}
while (true)
{
if (IsFirstRowHeader == false)
{
string[] parts = parser.ReadFields();
if (parts == null)
{
break;
}
dt.Rows.Add(parts);
}
IsFirstRowHeader = false;
}
}
gvDetails.DataSource = dt;
gvDetails.DataBind();
}
}
 

Answers (2)

0
Photo of Gautam Parmar
NA 872 2.2k 7y
Use a boolean field for status of delete yes or no
Accepted
0
Photo of Prem Sahani
NA 85 1.8k 7y
i have one simple program , suppose, one building is there,  have some facility, like Video Game, restuarents  elc..
when some one using those facility  so we can't delete from table...
 
thank you bro
0
Photo of Gautam Parmar
NA 872 2.2k 7y
While user delete row in store procedure update that row into isdeleted=1
 
and retriving data stored procedure will be select * Record where isDeleted=0
0
Photo of Tapan Patel
NA 8.1k 101k 7y
Please explain little bit about what do you mean by table value and what is your expected output?