File does not exist on NAV-server

MortenSteengaard
Member Posts: 144
Hi,
I have made a codeunit that can import a csv file. It works fine on the NAV-server, when I select a file from C-drive. When I run NAV on the terminal server and select a file from C-drive, I get the message "The file C:\Temp\myFile.csv was not found".
It looks like I need to specify that my codeunit must be run on the client, but how do I do that?
My codeunit OnRun trigger starts with this:
fileName := FileMgt.OpenFileDialog('choose file','','CSV files|*.csv|All files|*.*');
IF fileName = '' THEN EXIT;
CLEAR(myFile);
myFile.OPEN(fileName, TEXTENCODING::UTF8);
myFile.CREATEINSTREAM(inStream);
I have made a codeunit that can import a csv file. It works fine on the NAV-server, when I select a file from C-drive. When I run NAV on the terminal server and select a file from C-drive, I get the message "The file C:\Temp\myFile.csv was not found".
It looks like I need to specify that my codeunit must be run on the client, but how do I do that?
My codeunit OnRun trigger starts with this:
fileName := FileMgt.OpenFileDialog('choose file','','CSV files|*.csv|All files|*.*');
IF fileName = '' THEN EXIT;
CLEAR(myFile);
myFile.OPEN(fileName, TEXTENCODING::UTF8);
myFile.CREATEINSTREAM(inStream);
0
Best Answer
-
The code happens on the NAV server, when you fileName := FileMgt.OpenFileDialog(XXXX) it browse the client.
When you use File.open(XXXX) you use server side.
The fix could be
ServerPath := FileMgt.UploadFileSilent(filename);
Myfile.open(ServerPath)For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.5
Answers
-
The code happens on the NAV server, when you fileName := FileMgt.OpenFileDialog(XXXX) it browse the client.
When you use File.open(XXXX) you use server side.
The fix could be
ServerPath := FileMgt.UploadFileSilent(filename);
Myfile.open(ServerPath)For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.5 -
Thanks, SanderDk!!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions