ivonsurf123
New member
- Joined
- Sep 13, 2024
- Messages
- 1
- Programming Experience
- Beginner
Hello,
How can I use textboxes to insert information from a text file locate in C:\ to populate the image on website, so far, I prepare the basic, but I am not sure how to do the rest.
Thank you.
This is the code so far:
How can I use textboxes to insert information from a text file locate in C:\ to populate the image on website, so far, I prepare the basic, but I am not sure how to do the rest.
Thank you.
This is the code so far:
C#:
{
public class ImageHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string FileUpload1 = context.Request.QueryString["FileUpload1"];
try
{
if (FileUpload1 == null) // Validation
{
context.Response.Write("No file Selected");
return;
}
else
{
//Code Here:
// Read and Extract Information from the Index.txt File:
string path = ConfigurationManager.AppSettings["ImageBasePath"];
var files = Directory.GetFiles(path, "index.txt", SearchOption.AllDirectories);
// Read and populate textboxes from Index.txt
string filePath = Path.Combine(files);
var lines = File.ReadAllLines(filePath);
List<string[]> parsedLines = new List<string[]>();
// Parse lines and prepare data
foreach (var line in lines)
{
var parts = line.Split('|');
if (parts.Length >= 9)
{
// Extract required information
string acctNumber = parts[0];
string chkNumber = parts[1];
string chkAmount = parts[2];
string imgDate = parts[5];
string imagePath = parts[8];
// Populate the textboxes
// Construct the full path to the image file
string fullImagePath = Path.Combine(path, imagePath);
// Populate the image from imagePath
}
}
}
}
catch (Exception ex)
{
// Handle any exceptions that occurred
Console.WriteLine("An error occurred while reading the file: " + ex.Message);
}
}