I have an excel .csv file that has some data in the below formats in cells:
NAME Address Contact
Shoeb Lko 675567
Rajesh Banaras 7687678
.csv file is not a text file having only .csv extension. It is a csv file that is made using Microsoft Excel file...For testing you can also make .csv file... For this (1) create an excel file (2) open this excel file (3) go to file menu and click on "save as" (4) select CSV(Comma Seperated) option in Save as type: ---- Now this is .csv file from which I will read content and write content also in a .csv file
I am trying to use C# to write another Excel .csv file in the same format.
Code that I am using is written below:
//Below line is reading file from system drive
StreamReader rd = new StreamReader("D:\FilesUploadedToTablet\drivers.csv", true);
//Below line is writing data to file existing in our site folder
StreamWriter wr = new StreamWriter(Server.MapPath(".") + "\filename\CSVFile.csv");
wr.Write(rd.ReadToEnd());
rd.Close();
wr.Close();
Here StreamReader is reading drivers.csv file but StreamWriter is not writing that content to the CSVFile.csv file. If I use any text file in place of .csv file then the content writes successfully. What am I doing wrong?
Server.MapPath(".")?