Results 1 to 20 of 20

Thread: When opening a file in Notepad

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2017
    Posts
    26

    When opening a file in Notepad

    welcome..
    I know that Notepad is not intended for displaying data and source code, but rather it is for displaying texts only, but something crossed my mind
    When we open a file or image in Notepad, the following codes appear.
    Name:  سؤس.jpg
Views: 332
Size:  43.3 KBName:  سؤس.jpg
Views: 332
Size:  43.3 KB
    Do these codes have a name?
    How does a computer process these codes and things?
    And if we say that there is a file of 2 megabytes
    How can I check the data and source code for this 2MB?

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

    Re: When opening a file in Notepad

    All files are stored in binary form. Whenever you open a file, that binary data has to be interpreted in some way. For a text file, the bytes in the file are converted to characters using some encoding, e.g. ASCII or some form of Unicode. If you open an image file or something else then the bytes don't represent text but a text editor like Notepad will interpret them that way, because that is all it knows. That is why you get gibberish: It's like if a bird was pecking on a tree trunk and you tried to interpret it using Morse code. You would get gibberish because the input wasn't intelligible text in the first place.

    How the computer processes the content of a file to make sense of it depends on the file type. Applications and the OS itself will generally take a hint as to what's in the file from the extension, but sometime they will also read a header in the file and if it conforms to a particular format then they will assume that the rest of the file is in that format.

    As for the question about file size, I'm not sure exactly what you're looking for. You've posted in a VB.NET forum so I assume that you want a VB.NET answer. You can create a FileInfo object for the specified file and get its Length property, which will be the number of bytes the file contains. Windows uses 1024 as a multiplier for file sizes, not 1000, so you would divide that number of bytes by 1024*1024 to get the number of megabytes. If you actually want to count the bytes yourself then you can call File.ReadAllBytes to get the file contents into a Byte array and then get the Length of that. What is it that you're actually trying to achieve?

  3. #3
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: When opening a file in Notepad

    Quote Originally Posted by jmcilhinney View Post
    For a text file, the bytes in the file are converted to characters using some encoding, e.g. ASCII or some form of Unicode.
    In this particular case it's trying to interpret the bytes as ANSI text(it's in the lower left of both images) which is whatever the current codepage on that machine is will be used to determine what characters the bytes represent.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2017
    Posts
    26

    Re: When opening a file in Notepad

    Thank you for the answer
    I want to get the binary code of a file or image via vb.net

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: When opening a file in Notepad

    Quote Originally Posted by Basil Abdallah View Post
    Thank you for the answer
    I want to get the binary code of a file or image via vb.net
    This:-
    Quote Originally Posted by jmcilhinney View Post
    you can call File.ReadAllBytes to get the file contents into a Byte array
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jun 2017
    Posts
    26

    Re: When opening a file in Notepad

    In short, I want a way through which I can copy a code or code for an image
    Then I transfer this code to another computer to open

    I want to make a project in Visual Basic through which I extract a code for a specific file (DeCompiler).

    And this code is sent to the other computer and the code is analyzed and a Compiler is made for it.

  7. #7
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: When opening a file in Notepad

    Quote Originally Posted by Basil Abdallah View Post
    In short, I want a way through which I can copy a code or code for an image
    Then I transfer this code to another computer to open

    I want to make a project in Visual Basic through which I extract a code for a specific file (DeCompiler).

    And this code is sent to the other computer and the code is analyzed and a Compiler is made for it.
    Are you looking at a way of transferring files between two computers? I am not entirely sure what you mean by extracting code for a specific file (DeCompiler) and then compiling it again.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jun 2017
    Posts
    26

    Re: When opening a file in Notepad

    Quote Originally Posted by PlausiblyDamp View Post
    Are you looking at a way of transferring files between two computers? I am not entirely sure what you mean by extracting code for a specific file (DeCompiler) and then compiling it again.
    No
    I want to extract the binary code of a file for a specific purpose (transfer this binary code to another computer (specifically in this way for a specific purpose))

    After the transfer, this binary system is converted to the original file

  9. #9
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: When opening a file in Notepad

    Quote Originally Posted by Basil Abdallah View Post
    No
    I want to extract the binary code of a file for a specific purpose (transfer this binary code to another computer (specifically in this way for a specific purpose))

    After the transfer, this binary system is converted to the original file
    Not really sure what you mean by "extract the binary code of a file", a file is nothing more than a collection of bytes. You can just read the bytes as Niya describes above.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jun 2017
    Posts
    26

    Re: When opening a file in Notepad

    Quote Originally Posted by PlausiblyDamp View Post
    Not really sure what you mean by "extract the binary code of a file", a file is nothing more than a collection of bytes. You can just read the bytes as Niya describes above.
    Can you give me a project example of how to extract the bytes of an image, for example?

  11. #11
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: When opening a file in Notepad

    I'm thinking Dodi's Decompiler...

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: When opening a file in Notepad

    Quote Originally Posted by Basil Abdallah View Post
    Can you give me a project example of how to extract the bytes of an image, for example?
    Why would we need to give you a project example? We've told you what to do. Just do it. It's not for us to write your code for you.

  13. #13
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: When opening a file in Notepad

    Quote Originally Posted by Basil Abdallah View Post
    Can you give me a project example of how to extract the bytes of an image, for example?
    What do you mean by "image"? Do you mean like an actual picture file like a JPG, BMP ect or do you mean "image" in a more general sense like a "binary image" which can mean like an EXE image? You need to be clear.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Jun 2017
    Posts
    26

    Re: When opening a file in Notepad

    Quote Originally Posted by jmcilhinney View Post
    Why would we need to give you a project example? We've told you what to do. Just do it. It's not for us to write your code for you.

    I really did not understand and need more details about extracting the files data..

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Jun 2017
    Posts
    26

    Re: When opening a file in Notepad

    Quote Originally Posted by Niya View Post
    What do you mean by "image"? Do you mean like an actual picture file like a JPG, BMP ect or do you mean "image" in a more general sense like a "binary image" which can mean like an EXE image? You need to be clear.
    Let me explain you immediately .. now when I send a file (a song or his image or any file) to someone online, the data of my file will be upload to the Internet to the ... I want to get this data I can copy it and save it and when i need to run that applcation do compiler to the data

  16. #16
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: When opening a file in Notepad

    Quote Originally Posted by Basil Abdallah View Post
    I really did not understand and need more details about extracting the files data..
    You've been told to call File.ReadAllBytes. Do it. If you don't understand how then find out on the internet. You don't need us to provide every detail when there's so much information out there already. Did you bother to read the documentation for that method? Did you search the wen for existing examples? Of course you didn't. You just sat on your hands and waited for others to make the effort that you won't.

  17. #17

    Thread Starter
    Junior Member
    Join Date
    Jun 2017
    Posts
    26

    Re: When opening a file in Notepad

    Quote Originally Posted by jmcilhinney View Post
    You've been told to call File.ReadAllBytes. Do it. If you don't understand how then find out on the internet. You don't need us to provide every detail when there's so much information out there already. Did you bother to read the documentation for that method? Did you search the wen for existing examples? Of course you didn't. You just sat on your hands and waited for others to make the effort that you won't.
    You're totally wrong!!! I didn't come to this forum until after I lost hope.
    And I have already said that this method (File.ReadAllBytes) does not work,
    Say good And give me the tip of the thread Or you can just ignore me.

  18. #18
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: When opening a file in Notepad

    Quote Originally Posted by Basil Abdallah View Post
    Let me explain you immediately .. now when I send a file (a song or his image or any file) to someone online, the data of my file will be upload to the Internet to the ... I want to get this data I can copy it and save it and when i need to run that applcation do compiler to the data
    I don't understand. You want to download a file someone sent? You want to upload? What does copying have to do with this? I know you know what you mean but you must understand, your English is very hard to parse. Whatever you are using to translate to English is not being clear enough. When talking about writing a program, details matter so much more than they would in a typical everyday conversation.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  19. #19
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: When opening a file in Notepad

    Quote Originally Posted by Basil Abdallah View Post
    I have already said that this method (File.ReadAllBytes) does not work
    Except it does work to get the data contained in a file. If it doesn't do what you want then what you want is not to get the content of a file. If you can't explain what you actually want, there's not much chance of our helping you achieve it. We're almost at 20 posts in this thread and either no one knows what you're talking about or you already have your solution but won't use it. Neither reflects well.

  20. #20
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,871

    Re: When opening a file in Notepad

    I think he wants some like sending a file to another computer.
    Like WhatsApp in which you select a picture file and the image is transmitted to the receiver and shown on the screen

    ReadAllBytes get the data from his local computer, but it needs to be send to some other computer and either be stored or/and displayed.

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