Try Microsoft Edge
A fast and secure browser that's designed for Windows 10
There is a need for development for reading and writing the file in Client directory in NAV 2013 R2 and later will be required in other versions too. Since the 'File' variable File.CREATE and WRITE functions create file in NAV Server, I am using following DOTNET assemblies:
1. DotNet System.IO.File.'mscorlib' 2. DotNet System.IO.Directory.'mscorlib' 3. DotNet System.IO.FileStream.'mscorlib'
I've also set the RunOnClient property to 'Yes' which will create the files in local directory.
However the Dotnet assembly code 'File.Create' creates the file in local directory of client, when the code to File.Write is called NAV throws a lock by another user error. Please let me know the required code, if anybody have writting a code to create file in Local directory using dot net assemblies.
I would recommend you to use the File Management Codeunit 419 instead of dotnet.
Walkthrough: Transferring a File from Microsoft Dynamics NAV Server to the Client
Thanks, But I've resolved it by myself. I will post the solution later.
File management was not a solution to me, as it does not allow to write and read data from file.
In short, I've created all the .Net assembly as 'RunOnClient' and did all the write and read transactions using the mscorlib class file, fileInfo , Streamwriter and StreamReader.
The problem is resolved.
You only need the 'DotNet System.IO.File.'mscorlib' ' to create the file in the location. It must store the return value in 'System.IO.FileStream.'mscorlib'' and then close the filestream when created. Later on, use the stream writer to write the data into file.
In my case:
CASE ProcessFileL."Character Set" OF
StreamWriterL := StreamWriterL.StreamWriter(OutputFileNameL,AppendFileL,EncodingL.ASCII);
StreamWriterL := StreamWriterL.StreamWriter(OutputFileNameL,AppendFileL,EncodingL.Default);
StreamWriterL := StreamWriterL.StreamWriter(OutputFileNameL,AppendFileL,EncodingL.UTF8);
StreamWriterL = DotNet : System.IO.StreamWriter.'mscorlib'.
Do message me if anyone require further details on file handling. ;)