Writing a TXT or log File - UnauthorizedAccessException

First Option

Ice.Diagnostics.Log.WriteEntry("YourMsg");

It shows up in Epicors ServerLog.txt along with all the other logging such as BPM Execution etc. You can then access it via UNC Path if you have access or just the Web URL

http://MyServer/EpicorERP/ServerLog.txt

Second Option

Third Option
You can get the ServerLog Path (EpicorData) and it will allow you to write there. I need to find the helper Method but something like

Ice.Lib.FileName.ServerFileType.ServerLog
// You include Ice.Lib.Shared.dll as a reference in your BPM

string fullFilePath = Ice.Lib.FileName.Get("YourFileName", Ice.Lib.FileName.ServerFileType.Log);

Possible Options are:

    public enum ServerFileType
    {
        Log = 1,
        Temp = 2,
        Report = 3,
        Process = 4,
        ServerLog = 5,
        ServerTemp = 6,
        Custom = 7,
        UserData = 8
    }

Extra:
Im a big fan of writeFileLib because if multiple users are running the same BPM, you wont get file in use exceptions etc…

Ice.Lib.writeFileLib.FileWriteLine("YourPath/FileName.txt", ".......");

So Maybe something like

string fullFilePath = Ice.Lib.FileName.Get("Testing.txt", Ice.Lib.FileName.ServerFileType.Log);
Ice.Lib.writeFileLib.FileWriteLine(fullFilePath , "...hello....");

Lastly,
There is also PathHelper (I think this is Client side if i recall)

PathHelper.GetFolderPath(SpecialFolder.Attachment);

Possible Options:

public enum SpecialFolder
{
    Report,
    WebDeployment,
    ReportDefinition,
    CustomReportDefinition,
    UserData,
    CompanyData,
    EWADeployment,
    Attachment
}
3 Likes