How to open windows file using

Create, write, and read a file

Important APIs

Read and write a file using a StorageFile object.

В For a complete sample, see the File access sample.

Prerequisites

Understand async programming for Universal Windows Platform (UWP) apps

You can learn how to write asynchronous apps in C# or Visual Basic, see Call asynchronous APIs in C# or Visual Basic. To learn how to write asynchronous apps in C++/WinRT, see Concurrency and asynchronous operations with C++/WinRT. To learn how to write asynchronous apps in C++/CX, see Asynchronous programming in C++/CX.

Know how to get the file that you want to read from, write to, or both

You can learn how to get a file by using a file picker in Open files and folders with a picker.

Creating a file

Here’s how to create a file in the app’s local folder. If it already exists, we replace it.

Writing to a file

Here’s how to write to a writable file on disk using the StorageFile class. The common first step for each of the ways of writing to a file (unless you’re writing to the file immediately after creating it) is to get the file with StorageFolder.GetFileAsync.

Writing text to a file

Write text to your file by calling the FileIO.WriteTextAsync method.

Writing bytes to a file by using a buffer (2 steps)

First, call CryptographicBuffer.ConvertStringToBinary to get a buffer of the bytes (based on a string) that you want to write to your file.

Then write the bytes from your buffer to your file by calling the FileIO.WriteBufferAsync method.

Writing text to a file by using a stream (4 steps)

First, open the file by calling the StorageFile.OpenAsync method. It returns a stream of the file’s content when the open operation completes.

Next, get an output stream by calling the IRandomAccessStream.GetOutputStreamAt method from the stream . If you’re using C#, then enclose this in a using statement to manage the output stream’s lifetime. If you’re using C++/WinRT, then you can control its lifetime by enclosing it in a block, or setting it to nullptr when you’re done with it.

Now add this code (if you’re using C#, within the existing using statement) to write to the output stream by creating a new DataWriter object and calling the DataWriter.WriteString method.

Lastly, add this code (if you’re using C#, within the inner using statement) to save the text to your file with DataWriter.StoreAsync and close the stream with IOutputStream.FlushAsync.

Best practices for writing to a file

For additional details and best practice guidance, see Best practices for writing to files.

Reading from a file

Here’s how to read from a file on disk using the StorageFile class. The common first step for each of the ways of reading from a file is to get the file with StorageFolder.GetFileAsync.

Reading text from a file

Read text from your file by calling the FileIO.ReadTextAsync method.

Reading text from a file by using a buffer (2 steps)

Then use a DataReader object to read first the length of the buffer and then its contents.

Reading text from a file by using a stream (4 steps)

How to Open a File/Folder in Command Prompt (CMD) Windows 10 [MiniTool News]

By Alisa | Follow | Last Updated December 31, 2020

Читайте также:  Зависает проводник windows как исправить

Summary :

Wonder how to open a file cmd or how to open a folder in Command Prompt on Windows 10? This tutorial provides a step-by-step guide. Also, if you can’t find some files or folders in Windows 10, or some files are unexpectedly lost in your Windows 10 computer, MiniTool free data recovery software for Windows 10/8/7 can help you easily recover lost files.

You can also open files from Command Prompt. Wonder how to open a file or folder in Command Prompt on Windows 10? Check the step-by-step guide in this tutorial.

How to Open a File CMD Windows 10 in 2 Steps

Step 1 – Open Command Prompt

You can press Windows + R keys on the keyboard to open Windows Run dialog. Then type cmd in the Run box. If you want to run Command Prompt as Administrator, you need to press Ctrl + Shift + Enter keys at the same time.

Alternatively, you can also click Start or Search box in Windows 10, and type cmd or command prompt. Right-click the Command Prompt app in the list and choose Run as administrator.

Step 2 – Open Files from Command Prompt

Normally you have two ways to open a file using cmd. One is to move the folder that the file is in, the other is to open the files directly in Command Prompt.

Method 1. How to open a file with cmd by moving to the folder firstly

  • You can use the cd command to move to the exact folder the file lies in. For instance, cd C:\Users\mini\Desktop.
  • After you are in the correct folder path, you can type the name of the file with its extension, e.g. “travel.png”, and hit Enter button to open it.

Windows 10 repair, recovery, reboot, reinstall, restore solutions. Learn how to create Windows 10 repair disk, recovery disk/USB drive/system image to repair Windows 10 OS issues.

Method 2. How to open a file using cmd directly

You can also choose to open files from Command Prompt on Windows 10 directly, instead of going to the folder path. You can input the full path, file name and its file extension to open the target file, e.g. “C:\Users\mini\Desktop\travel.png”.

You can also freely specify an app to open the file. You need to type the whole path of the app ahead of the path of the file. For example, C:\Users\mini\”%windir%\system32\mspaint.exe” “C:\Users\mini\Desktop\travel.png”.

How to Open a Folder in Command Prompt Windows 10

You can also open a folder from Command Prompt with the command line below.

After you enter into Command Prompt window by following the operation above, you can open a folder in File Explorer in Command Prompt. The command line can be like this, start %windir%\explorer.exe “C:\Users\mini\Desktop”.

Tip: Need to mention that you need to enclose the path of a file or folder in double quotation marks, since some folder or files names have spaces in them.

To Recover Unexpectedly Lost Files or Folders in Windows 10

Sometimes you may suffer unexpected data loss in Windows 10 due to various reasons, e.g. system crash, Blue Screen error (e.g. Bad Pool Caller BSOD error), power outage, malware/virus infection, hard drive failure, etc. To easily recover lost data for free, you can choose the best free data recovery software to realize it.

MiniTool Power Data Recovery, a 100% clean and free data recovery software for Windows 10/8/7, enables you to easily recover mistakenly deleted files or lost files from computer local drive, external hard drive, SSD drive, USB drive (pen drive data recovery), SD card, and more.

Easy 3 steps to fast recover my files/data for free with best free file recovery software. 23 FAQs and solutions for how to recover my files and lost data are included.

  • Facebook
  • Twitter
  • Linkedin
  • Reddit
Читайте также:  Java lang nullpointerexception linux

ABOUT THE AUTHOR

Position: Columnist

Alisa is a professional English editor with 4-year experience. She loves writing and focuses on sharing detailed solutions and thoughts for computer problems, data recovery & backup, digital gadgets, tech news, etc. Through her articles, users can always easily get related problems solved and find what they want. In spare time, she likes basketball, badminton, tennis, cycling, running, and singing. She is very funny and energetic in life, and always brings friends lots of laughs.

Find and Open Files Using Command Prompt in Windows 10

Do you ever drive yourself crazy looking for all the files you need for a project? Have you saved them in unknown places on your computer? Can you only remember part of the name you gave the file? If any of these apply to you, using the command prompt instead of Windows Explorer may help you quickly find the files you need and allow you to open them directly from that location.

We have to mention, though, that it’s a waste of time using the Command prompt to open simple, trivial files. However, this method is something you should definitely look at when dealing with multiple files and assorted file types in random folders.

Opening Command Prompt

To search for the files you want, first launch Command Prompt. There are several ways to do this.

  • Type cmd in the Windows search box, then click on the icon to open the window. It’s preferred to run the command prompt as an administrator.

  • Use the Run window. A fast way to launch this window is to press the Win + R keys on your keyboard. Then, type cmd or cmd.exe and press Enter or click OK.

  • Use Cortana if it works for you properly: as soon as you see the Cortana is “listening” text, say “open command prompt,” and it will open up.

Search for your files

In the command prompt, type dir «\search term*» /s , but replace the words “search term” with text you want to find by using the file name. In the following screen, we are trying to search for a folder/file named “movies.”

The correct file path can be easily identified by the size of the folder. Once you have typed in the command, press Enter, and the search begins. It may look like nothing is happening for a second or two, though. But soon all the file paths mentioning the correct file or folder will be identified and named.

What do all the terms in the command mean?

  • dir is a command used to show files in the current directory but which can also locate data anywhere in the system.
  • The backslash tells dir to search from the root directory of the current drive.
  • /s tells dir to search all subdirectories.
  • Finally, * is used by command-line apps as a wildcard. It indicates that the search will locate all file names that contain your search term.
  • Putting an asterisk at the end of the name, like business* , will find all the files with your search term at the beginning of the name.
  • If you put it at the beginning, then your search will include only results with your text at the end. For example, *.jpg .
  • If you put an asterisk at each end of the search term, you will cover all the bases. No matter where your text is in the actual name of the file, that file will be listed in the results.

Change Command Prompt Directories for Precise File Location

If your target file is located in D: drive, you won’t find it anywhere in the Windows folder from the C: drive. Therefore, you should learn to change the drive path as shown below.

Читайте также:  Pantum m7300fdn ������� ��� linux

First, type cd.. , which will enable you to easily move one folder up. To go to D drive, just type d: , and the command prompt will now listen to the new drive.

Within the destination drive, you can search for the correct file once again using the dir «\search term*» /s command discussed in the previous section. Do take care to use the * wildcard, both at the beginning and end of the search term for a comprehensive search – especially if that folder has hundreds of files. It’s pretty common to make mistakes in the wildcards and backslash, which returns a “no label” error as shown below. If you type correctly, you will easily identify the folder path and the correct file name.

If the folder path is very long, you may want to copy-paste the entire thing. We have a detailed tutorial on how to cut-copy-paste in the Windows 10 command prompt. But the method is simple enough: use Ctrl + A to select the entire command prompt screen, then just release the mouse or trackpad click. This would make any part of the command screen selectable for a copy-paste action as shown below.

Open your Files in Windows 10 Command Prompt

Once you find the file you want to open, you can open it from this screen using its default program, without locating it in your file explorer.

First, change the directory to the immediate folder where the file is located. This can be done using cd followed by the entire folder path to the correct file. It’s common to make mistakes, so it’s better to copy-paste the entire folder path as discussed in the previous section. Once the correct directory menu has been opened, you can open any files there. Here it’s a folder, where I saved my personal collection of rented movies.

Enter the file name inside the quotation marks «..» as shown here. Press Enter and the file will open using its default application. Here it’s Movies and TV programs, which is set as my default application for .mp4 files.

The file, a Mel Gibson-led movie called “Get the Gringo,” opens from the command prompt.

You can open multiple files from the command prompt once you’ve opened the correct folder. Here we open another file called “Erin Brockovich.mp4” in the same folder.

The file, a Julia Roberts-led movie called “Erin Brockovich,” opens from the command prompt using the default app.

Once you’re done, you may want to move back to another folder in the command prompt. For this, use cd.. followed by a new drive name as shown below. Navigating your computer’s files using the command prompt is very similar to just doing it in a regular way from your File explorer.

Wrapping Up

If you are looking for all your files concerning one topic or just trying to find the one that is hiding among all the folders in your computer, try using the command prompt. It may make it more efficient for you.

Amazingly, the command prompt is way faster and more responsive than opening the files from the File Explorer. This is true for video files, Windows Photos, Word documents, and heavy-duty games. The reason for this is that the GUI always consumes more memory and slows down the processes.

Related:

Sayak Boral is a technology writer with over ten years of experience working in different industries including semiconductors, IoT, enterprise IT, telecommunications OSS/BSS, and network security. He has been writing for MakeTechEasier on a wide range of technical topics including Windows, Android, Internet, Hardware Guides, Browsers, Software Tools, and Product Reviews.

Оцените статью