Omar
9
Q:

c# get path without filename

Input : 

string strPath = "c://myfiles//ref//file1.txt";

//function call to get the filename
filename = Path.GetFileName(strPath);

Output :

file1.txt
2
    string fileAndPath = @"c:\webserver\public\myCompany\configs\promo.xml";

    string currentDirectory = Path.GetDirectoryName(fileAndPath);

    string fullPathOnly = Path.GetFullPath(currentDirectory);
0
var fn = openFileDialogSapTable.FileName;
var currentPath = Path.GetFullPath( fn );
currentPath = Directory.GetParent(currentPath).FullName;
0

New to Communities?

Join the community