Delete file on Client

lollygag
Member Posts: 7
Hi
Here is my problem.
User wants to link a file on their pc (using the RTC).
When link is saved the file is uploaded to the server, and the link is changed.
File on the client needs to be deleted.
I have sucessfully (after lots of trial and error) managed to upload the file and change the URL in the link. However I cannot seem to delete the original file from the client.
Any ideas greatly appriciated...
Here is my problem.
User wants to link a file on their pc (using the RTC).
When link is saved the file is uploaded to the server, and the link is changed.
File on the client needs to be deleted.
I have sucessfully (after lots of trial and error) managed to upload the file and change the URL in the link. However I cannot seem to delete the original file from the client.
Any ideas greatly appriciated...
0
Answers
-
Yes, this RTC client is strange in a way.
Could you show how you did the upload and change? I want to do something simular. I have some code for the delete on the client. Will let you know tomorrow.0 -
You can create an instance of the FileSystemObject on the client side through automation and use it to delete the file.Rob Hansen
http://www.epimatic.com0 -
Hi
How do I create an instance of the FileSystemObject on the client side?
I can see this option for dotNet but not Automation. And I only see the FileSystemObject as an automation.
Am I missing something really obvious? :oops:0 -
mdPartnerNL..
here is a link to the blog that got me this far.
http://blogs.msdn.com/b/nav/archive/201 ... g-box.aspx0 -
@lollygag
Could you show me the NAV source code of what you did?PROCEDURE EraseOnClient@1000000023(VAR vPtFileNamePath@1000000001 : Text[1024]); VAR LaScriptControl@1000000003 : Automation "{0E59F1D2-1FBE-11D0-8FF2-00A0D10038BC} 1.0:{0E59F1D5-1FBE-11D0-8FF2-00A0D10038BC}:'Microsoft Script Control 1.0'.ScriptControl"; CR@1000000002 : Text[1]; BEGIN IF ISSERVICETIER THEN BEGIN IF CREATE(LaScriptControl,TRUE,TRUE) THEN BEGIN CR := ' '; CR[1] := 13; LaScriptControl.Language := 'VBScript'; LaScriptControl.AddCode( 'set fso = createobject("Scripting.FileSystemObject")'+CR+ ''+CR+ 'function FileDelete(thisFile)'+CR+ 'if fso.FileExists(thisFile) then'+CR+ ' fso.DeleteFile thisFile'+CR+ 'end if'+CR+ 'end function'); LaScriptControl.Eval('FileDelete("'+vPtFileNamePath+'")'); END; END ELSE BEGIN IF EXISTS(vPtFileNamePath) THEN BEGIN ERASE(vPtFileNamePath); END; END; END;
Haven't tested it yet. Will do later this day when opening my project0 -
Thank you mdPartnerNL, that works great. Below is the code you requested.
I hope this helps.MoveRTC() FileToUpload := GetFilename(URL1); FolderName := GetFoldername(URL1); PurchSetup.GET; PurchSetup.TESTFIELD("Attachment Sharename"); FileVar.CREATETEMPFILE; FileVar.CREATEINSTREAM(IStream); DOWNLOADFROMSTREAM(IStream,'','<TEMP>', '',MagicPath); FileVar.CLOSE; FOR i := STRLEN(MagicPath) DOWNTO 1 DO BEGIN IF MagicPath[i] = '\' THEN BEGIN MagicPath := COPYSTR(MagicPath,1,i); i := 1; END; END; IF ISCLEAR(FileSystemObject) THEN CREATE(FileSystemObject,TRUE,TRUE); FileSystemObject.CopyFile(FolderName + '\' + FileToUpload,MagicPath + '\' + FileToUpload); UPLOADINTOSTREAM('','<TEMP>','',FileToUpload,IStream); NewFilepath := PurchSetup."Attachment Sharename" + GetFilename(URL1); FileVar.WRITEMODE(TRUE); FileVar.CREATE(NewFilepath); FileVar.CREATEOUTSTREAM(OStream); COPYSTREAM(OStream,IStream); FileVar.CLOSE; URL1 := NewFilepath; IF MODIFY THEN; GetFilename(str1 : Text[250]) : Text[250] WHILE STRPOS(str1,'\') > 0 DO BEGIN i+=1; str1 := COPYSTR(str1,STRPOS(str1,'\')+1); IF i > 50 THEN ERROR(''); END; EXIT(str1); GetFoldername(str1 : Text[250]) : Text[250] FOR i := STRLEN(str1) DOWNTO 1 DO BEGIN IF str1[i] = '\' THEN BEGIN str1 := COPYSTR(str1,1,i); i := 1; END; END; EXIT(str1 + '\');
0 -
and thank you. I like sharing0
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