Can you have a file saved in a directory structure?

wheretheidivides

Active Member
Licensed User
Longtime User
I would like to have a program that will send the user a file. I know how to get the email address and send the email.

I DO NOT want b4A to generate the file or anything to modify it. I have a XLS spreadsheet with a macro on it that combines several CSV files and does some other stuff. I created the XLS sheet but do not want anyone to mess with it. All I want to do is include this in one of B4A directories. That's it. There must be some command to include this or is it as simple as just including it in 'files'? If so, then what would be the code to find it with directory structure? Let's call the file 'StupidStuff.XLS'

If after the program is installed I can see the file, I can then have the user press a button to email it to himself. The user should not have to search for the file. The program should have a button to email it to himself.
==========================
I copied this file over to the files folder, imported t and used this code. Am I close? This gives and error when downloading from yahoo mail (regardless of what I name the extension).

Message.Attachments.Add(File.Combine(File.DirAssets, "Omporter.xlsm"))
 
Last edited:

Mahares

Expert
Licensed User
Longtime User
I do not think you can email directly from the assets folders as it is embedded in the app, but I know you can do this: Copy it to, say defaultExternal, then email it:
B4X:
If File.Exists(File.DirAssets,"Omporter.xlsm") Then
      File.Copy(File.DirAssets,"Omporter.xlsm",File.DirDefaultExternal,"Omporter.xlsm")
      Message.Attachments.Add(File.Combine(File.DirDefaultExternal,"Omporter.xlsm"))
Else
      msgbox("No file to email","")
      return
End If
 
Last edited:
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
That worked. Thanks. So I just added a file, then the program saved it and then I could e-mail it out. I was wondering why all of those files come up with a 0 file length. No I know. Sweet.

==================================
For those reading,
File.Copy(File.DirAssets,"Omporter.xlsm "
has and extra space after xlsm so it needs to be
File.Copy(File.DirAssets,"Omporter.xlsm"
to get it to work.
 
Upvote 0
Top