1. Subj
2. How can I get a full path to a current directory?
3. How can I place some string in this path string in _HERE_:
"c:/some foler/more folders/myFileName_HERE_.ext"
1. Subj
2. How can I get a full path to a current directory?
3. How can I place some string in this path string in _HERE_:
"c:/some foler/more folders/myFileName_HERE_.ext"
1.)
2.)Code:public bool SomeClass::IsFileEmpty(string fileName)
{
bool _ret = false;
try
{
FileStream fs = File.OpenRead(strFileName);
_ret = (fs.Length == 0);
}
catch (Exception e)
{
throw new Exception("IsFileEmpty method exception", e);
}
return _ret;
}
Full path to the current directory or full path to the directory where your executable is stored???
Current dir:
Path to the executable:Code:string currentDir = System.AppDomain.CurrentDomain.SetupInformation.DynamicBase;
3.)Code:string path = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
MartinCode:public string SomeClass::AppendFileName(string path, string appendText)
{
// you have to check if the path or appendText are valid (not null) and if the path is really path to the file before this code...
string _ret = path.Substring(0, path.LastIndexOf('.')) +
appendText + path.Substring(path.LastIndexOf('.'));
return _ret;
}
Wow thanx!