save image automatically (coding) to resources.resx in vb.net - vb.net

How can I create and automatically save a picture to resources.resx in vb.net?
I tried but it only saves to the resources folder. What I want is to automatically save it to the resources inside the vb. Thank you.

I don't know if this is possible, but why don't you just save it to a custom folder? Maybe even in your application folder (Debug) so that you only have to access it with it's name.
I suggest you save it in a folder that you make in your debug folder, maybe call it Images. Then just save the image to the folder and you're done. After this you will always be able to access this image with dim ImagePath as String = "Images/yourpicture.jpg"
I assume you know how to save an image?
Image.Save(ImagePath, System.Drawing.Imaging.ImageFormat.Jpeg)

Related

Create Document in the Folder the EXE is in (VB)

I'm starting to play around with FileStream to make a text document. When you do this, you have to clarify a path. Is there a way to create the text document in the folder the EXE file is in?
(I'm asking this because this program is meant to be downloaded, so I think I can't clarify a path specific to my computer)
Thank you!
You're right, you can't bake a path into your program that is specific to your computer because then it won't work on the user's computer
Jimi makes the wise point that often programs are installed to C:\Program Files or similar and it's not automatically possible to write to subfolders in there - you'll have to get into asking the user for permission (Elevation) .. headache
Better to decide what you want the path for:
If you need a temporary path to e.g. download something to then throw it away you can call Path.GetTempFilename() or Path.GetTempPath() - the former creates a 0 byte file with a random name in the user's temp folder, and returns the path. The latter gives you the path to the temp folder so you can create your own file
If the file is to have some permanence, such as the user saving his work, you should ask the user for it. SaveFileDialog and FolderBrowserDialog are two things you can drop on your windows form and then call ShowDialog() on to show the uer a UI where they pick a path. After they OK or Cancel, you check if they OK'd or Cancel and proceed using the dialog's Filename or SelectedPath respectively (if they OK'd)
When you're writing your files it's easier not to use FileStream unless you really need to seek in the file etc. Easier to just:
System.IO.File.WriteAllText(path here, contents here)
If you have to write the contents of a string variable to a file
The best way to create a text file, would be to use CreateText method. It will create a file besides the executable program file. You can go the following way.
Dim sw as StreamWriter = File.CreateText("myfile.txt")
Dim str as String = "Your text"
sw.Write(str)
sw.Flush()
sw.Close()

change of location of the database dynamically in app running

Try to make my app read the ms-access database from shortcut of my database it failed to read, so try to change the location of database dynamically ( there is an option in the app to move the database to drop-box folder and create a shortcut to that database in app folder )
try to make an shortcut to the moved ms-database
the app to read the database or to change the location of database dynamically
First of all, you should create a folder with a clear name in your VB.Net application path, namely inside the project Debug folder, let's name that folder as "MyProjFiles", so it will be in this path: ProjectFolderName\bin\Debug\MyProjFiles
Put your whole projects files inside our lovely folder MyProjFiles, including all types of your attachments: database, images, sounds, files, etc.
Call your database or whatever of those attachments files in addition to our \MyProjFiles\ using this method: My.Computer.FileSystem.CurrentDirectory & "\MyProjFiles\YourFilesPathHere.EXT".
Now, the whole path will be such as this string: "C:\CurrentUserNam\RootFolder\ProjectFolderName\bin\Debug\MyProjFiles\YourFilesPathHere.EXT"
For great practical example of this, supposuply let's open our MSAccessDB.accdb which is already copied into our project folder \MyProjFiles\ by this code directly:
System.Diagnostics.Process.Start(My.Computer.FileSystem.CurrentDirectory() & "\MyProjFiles\MSAccessDB.accdb")
The result will be simply opening our database which called "MSAccessDB.accdb"
Or open some pdf files such as this line:
System.Diagnostics.Process.Start(My.Computer.FileSystem.CurrentDirector() & "\MyProjFiles\MyPdfFile.pdf")
and so on.
I hope this can help you all brothers.
Best ^_^ Regards.
You should read this link.
It explains how to read the information you need to give the access Datareader something to do.
.NET read binary contents of .lnk file
Maybe this is enough, so you don't need to copy anything.

Load picture from FTP to PictureBox with WinSCP .NET assembly

I am using WinSCP .NET assembly to transfer files by FTP. Couple days ago I developed new module to show pictures in PictureBox control. What I would like to achieve is to list picture's paths inside listbox or whatever else and then when click on this path to be able to open the picture in PictureBox. The point is pictures are on remote location on my FTP and I have no idea is it possible using WinSCP (FTP) to use get their path and then using the paths to show up given picture inside PictureBox. Anyone has idea is it possible or not?
You have to download the file to a local temporary file and load the file to the picture box. You cannot load the remote file directly.
' Unique temporary path
Dim tempPath As String = Path.GetTempFileName()
' Download the image
session.GetFiles(RemotePath.EscapeFileMask(remoteImagePath), tempPath).Check()
' Load tempPath to picture box
<your code here>
' Delete the temporary file
File.Delete(tempPath)
(I do not do VB.NET, so the syntax may not be 100% correct)

Create Folder and save file through fileopenDialog

i am using FileOpenDialog control to save file in C: drive,
Now i want to create New Folder and save the file in that folder with FileOpenDialog.
and also from other forms i have to store different file in that same foldr.
Please any one suggest me.
i think this link may help you
http://social.msdn.microsoft.com/Forums/vstudio/en-US/9bc2c92a-b22f-484c-9a15-0aebf639422d/folder-browser-dialog-in-vbnet-2010
by the way you should use SavefFileDialog or FolderBrowserDialog
First of all, you should use the SaveFileDialog to save the file. Not the file open dialog. The SaveFileDialog control will automatically let the user also create a folder -- just open the dialog in run-time mode and right click inside and see.. New > New Folder. Once the user navigates into this newly created folder and specifies the file name, all you need to do is to save the file.
Alternately, if you want to use a fixed subfolder, don't prompt the user to create the folder for you. Instead after the dialog is dismissed, do this --
string savePath = saveFileDialog1.FileName;
string directory = System.IO.Path.GetDirectoryName(savePath);
savePath = string.Format(
"{0}\\MySubFolder\\{1}",
directory,
System.IO.Path.GetFileName(savePath)
);
Save the file to the path in "savePath".
(PS: Sorry my above snippet is in C#, but you should be able to easily convert it to VB.NET).

Vb. how to make the file save files in a folder iam using the files in form

Lets Says I Want To Make A Think Like Saver Forum But Another Think Like
Folder Browser Diadlog Download / Save Files I Use In The Forum Not Load Then Save
Files I Use It And In The Folder They Select (Another Pc) I Want It To Save The Files/Download In The Folder And They Will Be Think Named Wolfteam.exe Thats Mean Start The Game And Use The Files In The Game Folder
Thanks For Help.