Results 1 to 6 of 6

Thread: [RESOLVED] Error On Embedded resources file even though the data is correct,

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2007
    Location
    Brunei Darussalam
    Posts
    50

    Resolved [RESOLVED] Error On Embedded resources file even though the data is correct,

    the story goes something like this:

    i have embedded resource file, a vbs script.
    i have an error when i use writeallbytes and it says dimensional error cannot be converted to bytes something like that so i decided to make a module instead of writeallbytes,

    what my program does is it writes the content of the script to textbox and after that
    this data will be written in a script and will be save on drive C:\ as .vbs.
    that is perfectly working on my codes
    Code:
    Friend Sub writeToFile(ByVal txt As String)
           Dim FILE_NAME As String = "C:\myvbs.vbs"
           My.Computer.FileSystem.WriteAllText(FILE_NAME, txt & vbnewline, True)
           MsgBox("bla blah" & vbCrLf & _
                  "blah blah" & vbCrLf & _
                  "Press Okey To Continue...")
    
       End Sub
    and the Go Button will call the vbs script
    the creation of vbs in drive C:\ is succesfull
    even the data inside of it is perfect.

    but why if im going to execute and call it with process.start it has an error?
    while the original vbs script when i run it doesn have error?

    although they have same data inside why?
    whats wrong with that?

    regards

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Error On Embedded resources file even though the data is correct,

    If I had to guess, and I do, I'd say that there's an issue with the working directory, which is often the cause of issues when using Process.Start. There's no way for us to know that for sure though when you don't tell us what the error is and where it occurs. If that is the issue then you'll need to create a ProcessStartInfo and set its WorkingDirectory to the path of the folder containing the file you're executing.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2007
    Location
    Brunei Darussalam
    Posts
    50

    Re: Error On Embedded resources file even though the data is correct,

    I'd say that there's an issue with the working directory
    so its better to use special folder for example the appdata folder?

    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

    i will try to do the screenshot with the error and i will post the code here later
    thanks sir

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Error On Embedded resources file even though the data is correct,

    Quote Originally Posted by eyestrain View Post
    so its better to use special folder for example the appdata folder?
    Assuming that this issue even is related to the working directory, where the folder is makes no difference whatsoever. All that matters is that you specify the correct working directory, which would normally be the folder containing the file you're executing.

    That said, it is never a good idea to save a file to the root of the system drive. Windows has lots of standard folders for various purposes and you should pretty much always be using one of those.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Member
    Join Date
    Dec 2007
    Location
    Brunei Darussalam
    Posts
    50

    Re: Error On Embedded resources file even though the data is correct,

    thanks sir for that
    now my file is save on the special folder location and still the same ,
    and i figure out that the problem!
    It has issue on how my vbs was created,

    for example we write the vbs script with notepad we usually do the encoding as ANSI
    now my script was not

    Now i resave it again with ANSI and it does work,
    now this is my last question which probably will solve my problem

    how can i make it a vbs script with ANSI encoding?

    in my project property, resources and in resources property which of this encoding should i choose sir?




    i thought the default is the windows ANSI?
    but still error on that...

    thanks
    Attached Images Attached Images  
    Last edited by eyestrain; Mar 29th, 2012 at 11:51 PM.

  6. #6

    Thread Starter
    Member
    Join Date
    Dec 2007
    Location
    Brunei Darussalam
    Posts
    50

    Re: Error On Embedded resources file even though the data is correct,

    problem solve!

    i make it default encoding and i add this code on my codes

    IO.File.WriteAllText(FILE_NAME, txt, System.Text.Encoding.Default)
    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width