I want to merge two files and save it is as new file.
e.g
a1,a2 new a3
...and then upload that file which i have merge which is a3.
I mean I am saving a file in a folder , i want when i save , i get exactly that f filename as well filepath.
here is my code.
protected void Button1_Click(object sender, EventArgs e)
{
string fname = "";
if (txtFile.HasFile)
{
try
{
HttpFileCollection uploadedFiles = Request.Files;
// Get the HttpFileCollection
string[] filespath = new string[15];
for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile hpfiles = uploadedFiles[i];
fname = Path.GetFileName(hpfiles.FileName);
if (hpfiles.ContentLength > 0)
{
hpfiles.SaveAs(Server.MapPath("~/Images/") + Path.GetFileName(hpfiles.FileName));
hpfiles.SaveAs(Server.MapPath(Path.Combine(@"~/Images/", fname)));
string filepath = Server.MapPath(@"~/Images/");
string path = filepath + fname;
filespath[i] = path;
}
}
// MergeFiles(@"C:\ENROLLDOCS\New Document.pdf"+DateTime.Now.ToFileTime(), filespath);
MergeFiles(@"D:\Razim\MedFlow\tempp\New Document.pdf" + " " + DateTime.Now.ToFileTime() + ".pdf", filespath);
// now i want to get the filename and filepath which i have merged and saved, for uploading.
}
catch (Exception ex)
{
Label1.Text = "The file could not be uploaded. The following error occured: " + ex.Message;
}
}
}