Hi
I have below code when i give outputStream.SaveToFile "c:\Image.jpg", 2 it saves the file.
When i save like below then it does not save the file
outputStream.SaveToFile "c:\" & "O_" & TrNo & "_" & Format(Date, "ddmmyyyy") & ".jpg", 2 ' 2: Overwrite if exists
Thanks
Mahesh ChandPosted Mar 21, 2025, 3:26 AM
Try to debug and see the value of the full path.
My recommendation is, concatenate one string at a time and debug to see their values and find the error.
In C#:
string str1 = @"c:\" + "O_" + TrnNo.ToString() + "_";
string str2 = str1 + Format..
Something like this. It must be some formatting issue.
Emily FosterPosted Mar 20, 2025, 1:59 PM
It seems like you are trying to save a file using the `outputStream.SaveToFile` method, but encountering an issue where the file is not being saved as expected.
From the code snippet provided, it looks like you are constructing the file path dynamically by concatenating the directory path with the file name. However, there might be a potential issue with the way the file path is being built.
When you have a statement like:
The resulting file path might end up being something like `c:\O_TrNo_Date.jpg`, where `TrNo` is a variable and `Date` is the current date format.
To debug this issue, you can try printing out the complete file path before calling the `SaveToFile` method to ensure that the constructed path is correct. Additionally, you can also check if the directory `c:\` exists and if the file name is being constructed properly with the expected values of `TrNo` and the formatted `Date`.
If the file is still not being saved, it's worth checking for any error messages or exceptions that are being thrown when attempting to save the file. This can help pinpoint the exact reason why the file is not getting saved as expected.
Feel free to provide more details or specific error messages if you need further assistance in troubleshooting this issue.