urgent copy image from hard Drive on local host
-
i am developing application in ASP.Net with C#. i am using button for FileOpenDialog to browse any image from hard drive as follows openFileDialog1.ShowDialog(); string s = openFileDialog1.FileName; textBox6.Text = s; problem is: i want the browsed image to be copied in local hosti.e,""C:\\Inetpub\\wwwroot\\15 WebSite\\images\\1.jpg" i have the follwing idea in mind File.Copy("C:\\Inetpub\\wwwroot\\15 WebSite\\images\\1.jpg", "C:\\Inetpub\\wwwroot\\15 WebSite\\images\\xyz.jpg"); or File.Copy(s.Substring(13,s.Length-13), "C:\\Inetpub\\wwwroot\\15 WebSite\\images\\xyz.jpg"); but i dont want to existing image to be overwrite, i want all images to ve saved in local host can anyone sugesst me what to do?
-
i am developing application in ASP.Net with C#. i am using button for FileOpenDialog to browse any image from hard drive as follows openFileDialog1.ShowDialog(); string s = openFileDialog1.FileName; textBox6.Text = s; problem is: i want the browsed image to be copied in local hosti.e,""C:\\Inetpub\\wwwroot\\15 WebSite\\images\\1.jpg" i have the follwing idea in mind File.Copy("C:\\Inetpub\\wwwroot\\15 WebSite\\images\\1.jpg", "C:\\Inetpub\\wwwroot\\15 WebSite\\images\\xyz.jpg"); or File.Copy(s.Substring(13,s.Length-13), "C:\\Inetpub\\wwwroot\\15 WebSite\\images\\xyz.jpg"); but i dont want to existing image to be overwrite, i want all images to ve saved in local host can anyone sugesst me what to do?
But what if the user(client) wants to copy a file from its machine to server
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
But what if the user(client) wants to copy a file from its machine to server
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
but my requirement is that in Windows application user is browsing image and clicking the "save" button to save it in database, i have to lauch the same image in website to i want the image to be copied in local host, can u suggest any solution for that
mavii wrote:
my requirement is that in Windows application user
But in your first query you posted that you are developing asp.net application . i don't have much idea about that but post your queries in right forum
Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "
-
i am developing application in ASP.Net with C#. i am using button for FileOpenDialog to browse any image from hard drive as follows openFileDialog1.ShowDialog(); string s = openFileDialog1.FileName; textBox6.Text = s; problem is: i want the browsed image to be copied in local hosti.e,""C:\\Inetpub\\wwwroot\\15 WebSite\\images\\1.jpg" i have the follwing idea in mind File.Copy("C:\\Inetpub\\wwwroot\\15 WebSite\\images\\1.jpg", "C:\\Inetpub\\wwwroot\\15 WebSite\\images\\xyz.jpg"); or File.Copy(s.Substring(13,s.Length-13), "C:\\Inetpub\\wwwroot\\15 WebSite\\images\\xyz.jpg"); but i dont want to existing image to be overwrite, i want all images to ve saved in local host can anyone sugesst me what to do?
As you are creating an ASP.NET application so I would suggest you to use FileUpload control to upload the said file to your server’s working directory. Here is a small example which does that: protected void UploadButton_Click(object sender, EventArgs e) { if(FileUploadControl.HasFile) { try { if(FileUploadControl.PostedFile.ContentType == "image/jpeg") { if(FileUploadControl.PostedFile.ContentLength < 102400) { string filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/") + filename); StatusLabel.Text = "Upload status: File uploaded!"; } else StatusLabel.Text = "Upload status: The file has to be less than 100 kb!"; } else StatusLabel.Text = "Upload status: Only JPEG files are accepted!"; } catch(Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; } } }
Regards, Amit Pal
-
As you are creating an ASP.NET application so I would suggest you to use FileUpload control to upload the said file to your server’s working directory. Here is a small example which does that: protected void UploadButton_Click(object sender, EventArgs e) { if(FileUploadControl.HasFile) { try { if(FileUploadControl.PostedFile.ContentType == "image/jpeg") { if(FileUploadControl.PostedFile.ContentLength < 102400) { string filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/") + filename); StatusLabel.Text = "Upload status: File uploaded!"; } else StatusLabel.Text = "Upload status: The file has to be less than 100 kb!"; } else StatusLabel.Text = "Upload status: Only JPEG files are accepted!"; } catch(Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; } } }
Regards, Amit Pal
but my requirement is that in Windows application user is browsing image and clicking the "save" button to save it in database, i have to lauch the same image in website to i want the image to be copied in local host "Server.MapPath" doesent work in Wndows application
-
but my requirement is that in Windows application user is browsing image and clicking the "save" button to save it in database, i have to lauch the same image in website to i want the image to be copied in local host, can u suggest any solution for that
mavii wrote:
but my requirement is that in Windows application user is browsing image and clicking the "save" button to save it in database,
Is images are stored in database ?
mavii wrote:
i have to lauch the same image in website to i want the image to be copied in local host, can u suggest any solution for that
Still I am not getting what you mean by this. 1 - Why user is browsing image from an windows application 2 - From where the user comes ? If the user is coming from another system, how can you copy the file to your local drive ? Please make your question more clear
-
mavii wrote:
but my requirement is that in Windows application user is browsing image and clicking the "save" button to save it in database,
Is images are stored in database ?
mavii wrote:
i have to lauch the same image in website to i want the image to be copied in local host, can u suggest any solution for that
Still I am not getting what you mean by this. 1 - Why user is browsing image from an windows application 2 - From where the user comes ? If the user is coming from another system, how can you copy the file to your local drive ? Please make your question more clear
actually i am developing two applications for the same organization using a single database, i am saving the record of "Wanted Criminals" in my wndowos application. the user of windows application opens a page to insert the record of new criminal, user also saves the picture of criminal using "FileOpenDialog" to browse any image saved in hard drive, so in database the path of "wanted criminal" is saved along with criminal names, age etc. problem is that in my website i want to display the picture of "Wanted criminal" along with his other information in da Datagrid, but in databast the path of Picture is saved as "E:\criminals\abc.jpg". website can display images placed in local host, so i wanted the image whom path is being saved in database through windows application should be copied with same name in "C:\Inetpub\www.root" have u got my problem can u plz suggest any solution?
-
actually i am developing two applications for the same organization using a single database, i am saving the record of "Wanted Criminals" in my wndowos application. the user of windows application opens a page to insert the record of new criminal, user also saves the picture of criminal using "FileOpenDialog" to browse any image saved in hard drive, so in database the path of "wanted criminal" is saved along with criminal names, age etc. problem is that in my website i want to display the picture of "Wanted criminal" along with his other information in da Datagrid, but in databast the path of Picture is saved as "E:\criminals\abc.jpg". website can display images placed in local host, so i wanted the image whom path is being saved in database through windows application should be copied with same name in "C:\Inetpub\www.root" have u got my problem can u plz suggest any solution?
mavii wrote:
user also saves the picture of criminal using "FileOpenDialog" to browse any image saved in hard drive, so in database the path of "wanted criminal" is saved along with criminal names, age etc.
Problem resides here. Because the file is in remote machine who uses the windows application. And you are trying to see that in your local ASP.NET application. This is not possible since you don't have a virtual path access to the file. Copying file from that machine to local machine is also not a good solution. You can solve this by keeping image in database as BLOB data. Check this[^] to get started with that. Hope this helps
-
mavii wrote:
user also saves the picture of criminal using "FileOpenDialog" to browse any image saved in hard drive, so in database the path of "wanted criminal" is saved along with criminal names, age etc.
Problem resides here. Because the file is in remote machine who uses the windows application. And you are trying to see that in your local ASP.NET application. This is not possible since you don't have a virtual path access to the file. Copying file from that machine to local machine is also not a good solution. You can solve this by keeping image in database as BLOB data. Check this[^] to get started with that. Hope this helps
ur idea must be right but i cant try it now, i have tried a method, can u plz suggest solution regarding this problem openFileDialog1.ShowDialog(); string s = openFileDialog1.FileName; textBox6.Text = s; string st = "abc1" + (count++) + ".jpg"; File.Copy(s.Substring(13, s.Length - 13), "C:\\Inetpub\\wwwroot\\15 WebSite\\images\\" + st); the subctring exactly returns the name og the picture PROBLEM IS: i want the image to be saved with the same name in local host as the Substing retun name "ABC.jpg" i want to save it with the same name in local host
-
mavii wrote:
user also saves the picture of criminal using "FileOpenDialog" to browse any image saved in hard drive, so in database the path of "wanted criminal" is saved along with criminal names, age etc.
Problem resides here. Because the file is in remote machine who uses the windows application. And you are trying to see that in your local ASP.NET application. This is not possible since you don't have a virtual path access to the file. Copying file from that machine to local machine is also not a good solution. You can solve this by keeping image in database as BLOB data. Check this[^] to get started with that. Hope this helps
can u suggest a solution for following problem public static int count = 0; private void button3_Click_1(object sender, EventArgs e) { openFileDialog1.ShowDialog(); string s = openFileDialog1.FileName; textBox6.Text = s; string st = "Pict" + (count++) + ".jpg"; File.Copy(s.Substring(13, s.Length - 13), "C:\\Inetpub\\wwwroot\\15 WebSite\\images\\" + st);} i want the image to be saved in local host with the same name as as it was present in hard drive (from where it was browsed) ur solution regarding BLOB must be right but i cant apply it right now:(