Click here to Skip to main content
14,638,655 members
Rate this:
Please Sign up or sign in to vote.
See more:
Dear Friends
I want to upload files in my project folder and path and date in database.
And then I want to read latest uploaded file ie on the basis of Date or ID.
After that I have to display latest files content on a web page in my project.

I have uploaded the text files in my projects folder and now I want to read the file on the base of MAX Id and want to show its content on a web page by using literal.
Please help me.

Thanks and Regards
Akhilesh Pathak
Posted
Comments
Ankur\m/ 8-Mar-13 4:13am
   
Start by Googling - 'read a file c#'. Replace the language name with what you are using.
OriginalGriff 8-Mar-13 4:33am
   
And what have you tried?
Where are you stuck?
Akhilesh Kumar Pathak 8-Mar-13 4:35am
   
I am not able to select the most recent file from the folder on the basis of ID in database.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You need to basic elements here: reading a text file and writing one.

To read a text file, use:
string FilePath;
FilePath = txtBoxInput.Text;
if (File.Exists(FilePath))
{
   textBoxContents.Text = File.ReadAllText(FilePath);
}


To write a text file, use:
DirectoryInfo Folder = new DirectoryInfo(textboxPath.Text);
if (Folder.Exists)
{
   if (textboxName.Text != string.Empty)
   {
      string FilePathSave = Folder.ToString() + textboxName.Text;
      File.WriteAllText(FilePathSave, textBoxContents.Text);
   }
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100