Copy File by selection to specific folder
hhhhhhhqat
Member Posts: 111
Hi ..
i create small form to collect some data for applicant , i add browse button to allow them for upload CV ... (not that meaning of upload )
i just want the applicant to browse the attached USB or any drive to select the CV document ( *.PDF or *.DOC) then the command will automatic make copy to specific folder ( C:\Applicant CV\ ) and give name of file by applicant NO+date+time.
can we do like that ????
thanks for every one helping me
i create small form to collect some data for applicant , i add browse button to allow them for upload CV ... (not that meaning of upload )
i just want the applicant to browse the attached USB or any drive to select the CV document ( *.PDF or *.DOC) then the command will automatic make copy to specific folder ( C:\Applicant CV\ ) and give name of file by applicant NO+date+time.
can we do like that ????
thanks for every one helping me
0
Comments
-
You can use OpenFile function of Common Dialog Management codeunit to let the user choose the file (take a look at report Import Budget from Excel for an example of usage) and File.COPY statement for copying, composing the target file name base on your requirement.* Daniele Rebussi * | * Rebu NAV Diary *0
-
i use this code
FileName := CommonDialogMgt.OpenFile(Text006,'',2,'',0);
FILE.COPY(FileName,'C:\cf\cv.pdf');
it give error " file already exist"
can you help me , i want every time different name based on selection and applicant No0 -
You need to "compose" the new file name and use it as second parameter of COPY function:
NewFileName := 'C:\cf\cv_' + FORMAT(ApplicantNo) + '_' + FORMAT(CURRENTDATETIME,0,'<Year4><Month,2><Day,2>-<Hours24><Minute,2><Second,2>') + '.pdf'; FILE.COPY(FileName,NewFileName);
* Daniele Rebussi * | * Rebu NAV Diary *0 -
perfect geordie
thanks for your usual help ...
only one thing how can i make the output ( *.pdf and *.doc) .. now i can save and reopen (*.PDF) only , other files is not recognized.
and also if the user select any files should not be accepted..
thanks again for your help0 -
You can manage it retrieving the extension from the original file:
NewFileName := 'C:\cf\cv_' + FORMAT(ApplicantNo) + '_' + FORMAT(CURRENTDATETIME,0,'<Year4><Month,2><Day,2>-<Hours24><Minute,2><Second,2>') + DELSTR(OldFileName,1,STRLEN(OldFileName)-4);
Of course this works only with 3 characters extensions, should be better to extract from the original file name the part after the last dot and use it in order to manage extensions like ".xlsx".* Daniele Rebussi * | * Rebu NAV Diary *0 -
Hi geordie
new code gives me below error..
Microsoft Business Solutions-Navision
The value of DELSTR parameter 3 is outside of the permitted range.
The current value is: -4.
The permitted range is: from 0 to 2147483647.
OK
0 -
hhhhhhhqat wrote:Hi geordie
new code gives me below error..
Microsoft Business Solutions-Navision
The value of DELSTR parameter 3 is outside of the permitted range.
The current value is: -4.
The permitted range is: from 0 to 2147483647.
OK
Please check the file name chosen by user, in this case seems empty (length = 0).* Daniele Rebussi * | * Rebu NAV Diary *0 -
i double check the file name ,, it seems OK .. is there any issue related to Version ( currently i am using 4.0) ..0
-
hhhhhhhqat wrote:i double check the file name ,, it seems OK .. is there any issue related to Version ( currently i am using 4.0) ..
No, it isn't related to the NAV version; you can add this check to control the error but I'm pretty sure it's related to a non-valid OldFileName value (how can you have a name, including the extension, shorter than 4 characters?):IF STRLEN(OldFileName) <= 4 THEN ERROR('File name not valid') ELSE NewFileName := 'C:\cf\cv_' + FORMAT(ApplicantNo) + '_' + FORMAT(CURRENTDATETIME,0,'<Year4><Month,2><Day,2>-<Hours24><Minute,2><Second,2>') + DELSTR(OldFileName,1,STRLEN(OldFileName)-4);* Daniele Rebussi * | * Rebu NAV Diary *0 -
i add the new code , it give me error " File name not valid "
the old file is " d:\sam cv new.pdf"
How can be the name include extension is less than 4.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 327 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
