1.)
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;
}
2.)
Full path to the current directory or full path to the directory where your executable is stored???
Current dir:
Code:
string currentDir = System.AppDomain.CurrentDomain.SetupInformation.DynamicBase;
Path to the executable:
Code:
string path = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
3.)
Code:
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;
}
Martin