<%@ Page Language="C#" %> <%@ Import Namespace="System" %> <%@ Import Namespace="System.IO" %> <script runat="server"> void Page_Load(Object Source, EventArgs E) { PathPropertiesLiteral.Text = ""; } void ParsePath(Object Source, EventArgs E) { StringBuilder PropertyContainer = new StringBuilder(); PropertyContainer.Append("<Table border='0' width='100%'>"); PropertyContainer.Append("<Tr><Td>Full Path</Td>"); PropertyContainer.Append("<Td>" + Path.GetFullPath(FileNameTextBox.Text) + "</Td></Tr>"); PropertyContainer.Append("<Tr><Td>Root Drive</Td>"); PropertyContainer.Append("<Td>" + Path.GetPathRoot(FileNameTextBox.Text) + "</Td></Tr>"); PropertyContainer.Append("<Tr><Td>Directory Path</Td>"); PropertyContainer.Append("<Td>" + Path.GetDirectoryName(FileNameTextBox.Text) + "</Td></Tr>"); PropertyContainer.Append("<Tr><Td>File Name</Td>"); PropertyContainer.Append("<Td>" + Path.GetFileName(FileNameTextBox.Text) + "</Td></Tr>"); PropertyContainer.Append("<Tr><Td>File Name (Without Extension)</Td>"); PropertyContainer.Append("<Td>" + Path.GetFileNameWithoutExtension(FileNameTextBox.Text) + "</Td></Tr>"); PropertyContainer.Append("<Tr><Td>File Extension</Td>"); PropertyContainer.Append("<Td>" + Path.GetExtension(FileNameTextBox.Text) + "</Td></Tr>"); PropertyContainer.Append("<Tr><Td>Temporary Filename</Td>"); PropertyContainer.Append("<Td>" + Path.GetTempFileName() + "</Td></Tr>"); PropertyContainer.Append("<Tr><Td>Temprary Filepath</Td>"); PropertyContainer.Append("<Td>" + Path.GetTempPath() + "</Td></Tr>"); PropertyContainer.Append("<Tr><Td>Directory Separator</Td>"); PropertyContainer.Append("<Td>" + Path.DirectorySeparatorChar + "</Td></Tr>"); PropertyContainer.Append("<Tr><Td>Alt Directory Separator</Td>"); PropertyContainer.Append("<Td>" + Path.AltDirectorySeparatorChar + "</Td></Tr>"); PropertyContainer.Append("<Tr><Td>Path Separator</Td>"); PropertyContainer.Append("<Td>" + Path.PathSeparator + "</Td></Tr>"); PropertyContainer.Append("<Tr><Td>Volume Separator</Td>"); PropertyContainer.Append("<Td>" + Path.VolumeSeparatorChar + "</Td></Tr>"); PropertyContainer.Append("<Tr><Td>Invalid Path Characters</Td>"); PropertyContainer.Append("<Td>" + Path.InvalidPathChars + "</Td></Tr>"); PropertyContainer.Append("</Table>"); PathPropertiesLiteral.Text = PropertyContainer.ToString(); } </script> <html> <head> <title>File Path Parsing</title> </head> <body> <form runat="server"> <h4>File Path Parser </h4> <h4> <asp:TextBox id="FileNameTextBox" runat="server"></asp:TextBox> <asp:Button id="ParsePathButton" onclick="ParsePath" runat="server" Text="Parse"></asp:Button> </h4> <hr /> </form> <asp:Literal id="PathPropertiesLiteral" runat="server"></asp:Literal> </body> </html>