Prompt user for Input
-
// Make sure a duplicate file doesn’t exist. If it does, keep on appending an incremental numeric until it is unique string sFilename = System.IO.Path.GetFileName(myFile.FileName); string ans; while (System.IO.File.Exists(Server.MapPath(sSavePath + sFilename))) { Console.Write("Do you want to overwrite? (Yes/No)"); ans = Console.ReadLine(); Console.WriteLine(""); } lblOutput.Text = "File already existed. A duplicate file has been created"; the logic is upload file -> if file exists -> prompt for user input -> if yes -> overwrite -> if no prompt for user input for new file name the code is not finished.. but am i on the right path??
-
// Make sure a duplicate file doesn’t exist. If it does, keep on appending an incremental numeric until it is unique string sFilename = System.IO.Path.GetFileName(myFile.FileName); string ans; while (System.IO.File.Exists(Server.MapPath(sSavePath + sFilename))) { Console.Write("Do you want to overwrite? (Yes/No)"); ans = Console.ReadLine(); Console.WriteLine(""); } lblOutput.Text = "File already existed. A duplicate file has been created"; the logic is upload file -> if file exists -> prompt for user input -> if yes -> overwrite -> if no prompt for user input for new file name the code is not finished.. but am i on the right path??
Seems a bit lost to me 1 - you're using server.mappath, but you're writing to the console, is this a server application or not ? 2 - sSavePath + sFilename, why not use Path.Combine ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Seems a bit lost to me 1 - you're using server.mappath, but you're writing to the console, is this a server application or not ? 2 - sSavePath + sFilename, why not use Path.Combine ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
1.sorry but what do you mean by server application? i'm doing asp.net c#.. images upload 2. oh path.combine works too? oh so ty lol
-
1.sorry but what do you mean by server application? i'm doing asp.net c#.. images upload 2. oh path.combine works too? oh so ty lol
OK, then this is a disaster. Your console code plainly is not going to work on a website, now is it ? If you asked in the right forum, I'd have known for sure this was ASP.NET. If the code stood any chance of working, I may have figured it out. C# code runs on te server, not the client.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )