vb.net - What is the file path, as a string, of a file in the application's resources? -


want to, I printed in asking that I run-time is because a file in the application of resources, the like:

  Private sub Button1_Click (ByVal as the System.Object, as ByVal e System.EventArgs) Button1.Click dim printProcess handle new process printProcess.StartInfo.CreateNoWindow = true printProcess .StartInfo.FileName as = "C: \ Users \ Geoffrey van wake \ documents \ Countdown_Timer_Help.rtf" printProcess.StartInfo.FileName = My.Resources.Countdown_Timer_Help printProcess.StartInfo.Verb = "Print" printProcess.Start () End Sub  

When I Use "C: \ Users \ GeFree Wayne Wake \ Document \ Countdown_Timer_Help.rtf" as the name of the argument of the file, it works. But when I use My.Resources.Countdown_Timer_Help, it says this file can not be found.

No, do not get it you did not, the file will only exist on your dev machine if you After deploying your program, the file will be embedded in your program and can not be printed. You must write code that saves the file from the resource to disk and then prints. For example:

  Personal sub btnPrint_Click (ByVal, in the form of this System.Object, as byVal e System.EventArgs) handle btnPrint.Click slow path string = Application.UserAppDataPath path = System as .IO.Path .Combine (path, "Help.rtf") System.IO.File.WriteAllText (path, My.Resources.Countdown_Timer_Help) dim printProcess new process printProcess.StartInfo.CreateNoWindow = true printProcess.StartInfo.FileName = Path as printProcess.StartInfo Action = "print" printProcess.Start () End Sub  

Given that you save the resource to a file, rather than just her it probably makes more sense Use the application to deploy the file with the application and embed it as a resource and to locate it on the disk and rewrite the file. To create that task at the time of debug timing, you must copy the file to bin \ Debug. By adding the file to your project with the project, add the + current item and copy settings to the output directory property to make new copies.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -