Moving file from one location to other location in AX 7
public static DMFLocalFilePath moveFile(DMFLocalFilePath _sourceFile, DMFLocalFilePath _destinationPath, Name suffix = "")
{
System.Exception ex;
Filename targetFileName;
System.IO.FileInfo fileInfo;
str fileName;
try
{
fileInfo = new System.IO.FileInfo(_sourceFile);
if (!fileInfo.get_Exists())
{
throw error("@DMF1029");
}
fileName = fileInfo.get_Name();
targetFileName = DMFGenerateSSISPackage::fileCheckPath(_destinationPath) + suffix + fileName;
fileInfo = new System.IO.FileInfo(targetFileName);
if (fileInfo.get_Exists())
{
fileInfo.Delete();
}
if (_sourceFile && targetFileName)
{
try
{
System.IO.File::Move(_sourceFile, targetFileName);
}
catch
{
throw error("@DMF1948");
}
}
}
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
error(ex.ToString());
}
return targetFileName;
}
{
System.Exception ex;
Filename targetFileName;
System.IO.FileInfo fileInfo;
str fileName;
try
{
fileInfo = new System.IO.FileInfo(_sourceFile);
if (!fileInfo.get_Exists())
{
throw error("@DMF1029");
}
fileName = fileInfo.get_Name();
targetFileName = DMFGenerateSSISPackage::fileCheckPath(_destinationPath) + suffix + fileName;
fileInfo = new System.IO.FileInfo(targetFileName);
if (fileInfo.get_Exists())
{
fileInfo.Delete();
}
if (_sourceFile && targetFileName)
{
try
{
System.IO.File::Move(_sourceFile, targetFileName);
}
catch
{
throw error("@DMF1948");
}
}
}
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
error(ex.ToString());
}
return targetFileName;
}
No comments:
Post a Comment