-
-
Save csharpforevermore/7774504 to your computer and use it in GitHub Desktop.
Uploads a file to the server and save it to disk. (INCOMPLETE)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool UploadToServer(string pathToFile) | |
{ | |
bool failure = false; | |
if (!FileUpload1.FileName.ToLowerInvariant().EndsWith(".xml")) { | |
failure = true; | |
} | |
StreamReader reader = new StreamReader(FileUpload1.FileContent); | |
string xmlContent = reader.ReadToEnd(); | |
if (!xmlContent.TrimStart().StartsWith("<?xml")) { | |
failure = true; | |
} | |
if (!failure) { | |
Label1.Text = "Only xml files can be uploaded."; | |
} else { | |
FileUpload1.SaveAs(this.Server.MapPath("TestData.xml")); | |
Label1.Text = "File Uploaded: " + FileUpload1.FileName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment