Finding Server Side files

Mikael_Smith_Larsen
Member Posts: 7
Hi Everybody
I have a problem with finding files on the Server. What I from the start wanted to do, was to copy a file in the TEMPORARYPATH to new name so that I could attach a file with more a meaningful name to an eMail, but the function: WshFileSystemObject.FileExists(txtSrcFileName) all was returns false.
How can this be done in Nav2013?
I have made 2 pieces of test code that runs on R2 and on Nav2013, in the R2 I can find the file, but not on the Nav2013 file isn’t found.
Nav2009 R2
Nav2013 Beta
Hoping someone can help.
Best regards
Mikael Smith Larsen
I have a problem with finding files on the Server. What I from the start wanted to do, was to copy a file in the TEMPORARYPATH to new name so that I could attach a file with more a meaningful name to an eMail, but the function: WshFileSystemObject.FileExists(txtSrcFileName) all was returns false.
How can this be done in Nav2013?
I have made 2 pieces of test code that runs on R2 and on Nav2013, in the R2 I can find the file, but not on the Nav2013 file isn’t found.
Nav2009 R2
// Var : WshFileSystemObject Automation 'Windows Script Host Object Model'.FileSystemObject txtSrcFileName := TEMPORARYPATH + 'Source.txt'; // The file Source.txt does exists in the Temp Folder for the R2 server txtNewFileName := TEMPORARYPATH + 'Target.txt'; CREATE(WshFileSystemObject,TRUE, FALSE); // Created with Server Side Parameters IF WshFileSystemObject.FileExists(txtSrcFileName) THEN MESSAGE('Wsh File fonnd : %1', txtSrcFileName); // The message is shown, since the is fond on the Server
Nav2013 Beta
// Var : WshFileSystemObject Automation 'Windows Script Host Object Model'.FileSystemObject // FileHelper DotNet System.IO.File.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' txtSrcFileName := TEMPORARYPATH + 'Source.txt'; // The file Source.txt does exists in the Temp Folder for the NAV2013 Server CREATE(WshFileSystemObject,TRUE,TRUE); // Created with Client Side Parameters IF WshFileSystemObject.FileExists(txtSrcFileName) THEN MESSAGE('Wsh File Found : %1',txtSrcFileName); // The message is Never shown IF FileHelper.Exists(txtSrcFileName) THEN MESSAGE('DotNet File Found : %1',txtSrcFileName); // The message is Never shown
Hoping someone can help.
Best regards
Mikael Smith Larsen
0
Comments
-
Try this :
FileHelper : dotnet : System.IO.File.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Bool := FileHelper.Exists("you file") with RunOnClient properties = False
Avallack.Navision Technical Consultant & .Net Developer0 -
Mikael Smith Larsen wrote:Hi Everybody
Nav2013 Beta// Var : WshFileSystemObject Automation 'Windows Script Host Object Model'.FileSystemObject // FileHelper DotNet System.IO.File.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' txtSrcFileName := TEMPORARYPATH + 'Source.txt'; // The file Source.txt does exists in the Temp Folder for the NAV2013 Server CREATE(WshFileSystemObject,TRUE,TRUE); // Created with Client Side Parameters IF WshFileSystemObject.FileExists(txtSrcFileName) THEN MESSAGE('Wsh File Found : %1',txtSrcFileName); // The message is Never shown IF FileHelper.Exists(txtSrcFileName) THEN MESSAGE('DotNet File Found : %1',txtSrcFileName); // The message is Never shown
Maybe I miss something but.. if your file is on NAV2013 server why do you create your automation on Client?
Another question... which is the value of the property "RunOnClient" of your FileHelper variable?~Rik~
It works as expected... More or Less...0 -
NAV2013 Server runs 64bit so therefore COM Automation does not work, i guess RunOnClient is always True so using Automation on server is not possible, Use DotNet Interop (As already suggested) instead.
But Since you create your Automations with RunOnClient = TRUE anyway this can't have worked previously on NAV2009, you explicitly instanciate the object on the client by yourself.
And last one: why don't you just use EXISTS() Function, it's always executed on the server, so this should give expected result.0 -
Hi Everybody
Thanks for the answers they were very helpful.
The solution for me was to use the DotNet: System.IO.File.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and set the Property: RunOnClient=No. After that it all works fine.
Regarding the Creating of the Automation variable: WshFileSystemObject, the function CREATE() is changed in Nav2013 so it is only allow to create objects on the Client.
Once Again Thanks
Mikael Smith Larsen0 -
Mikael Smith Larsen wrote:Hi Everybody
Thanks for the answers they were very helpful.
The solution for me was to use the DotNet: System.IO.File.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and set the Property: RunOnClient=No. After that it all works fine.
Regarding the Creating of the Automation variable: WshFileSystemObject, the function CREATE() is changed in Nav2013 so it is only allow to create objects on the Client.
Once Again Thanks
Mikael Smith Larsen
You can use au dotnet var instead of automation ... it's has been method from Navision 2013Navision Technical Consultant & .Net Developer0
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