I have a function which runs to insert a filename and a part number into a table. however the filename which gets inserted includes the whole directory e.g. c:\:folder\uploads\xml\file.xml
I would like just file.xml
string source = System.Web.HttpContext.Current.Server.MapPath("/uploads/xml/");
part retrun = null;
string[] fileEntries = Directory.GetFiles(source);
foreach (string fileName in fileEntries)
{
XmlSerializer serializer = new XmlSerializer(typeof(file));
Stream reader = new FileStream(fileName, FileMode.Open);
file f = (file)serializer.Deserialize(reader);
string part = "";
foreach (part p in f.@class.part)
{
part = p.tcpn.ToString();
XMLProductQueries.InsertIntoXMLProducts(context, fileName, part);
}
reader.Close();
}
help?
Use
Path.GetFileName(fileName)to extract the file name from your path.