File type

i want to open a file which is in type : “file” and it presents is in some given folder path
and i want to open that file in notepad how to do this?

Hi @sowmya
I would suggest looking at either the Open Application or Start Process activities. Use the path to notepad for the application or process (which I believe is in your Windows folder). Then, for arguments use the full path to the file you want to open. (If you do this in Start Process you need the argument surrounded by quotes to work)

i have tried this one but i want to open a file which is in format/type: "file "
i want to open that file in notepad how to do this

example:myfile is in file format
if want to open this file in notepad rightclick->openwith->notepad

Using startprocess activity
i am able to open the folder but not able to open a file in notepad

so assuming the filename is something like this
“filename.file”

In Start Process, use the path to notepad for process like
“C:\Windows\notepad.exe”

Then, for Argument use the filepath like
“”“”+directory+“\filename.file”“”

The extra quotes are needed because you need quotes if there are spaces. It’s similar to commandline scripting.

The alternative to this is the Open Application activity which may be more user friendly, and fill out the application and argument similarly.

Hope this explains it better.
Thanks.

Hello!

There are two ways to do this:

  1. You just have to move your file and rename with a .txt extension. Then open it with Open application (Notepad)

  2. Use the following code: System.Diagnostics.Process.Start(“Notepad.Exe”, documentPath)

Here’s a xaml example of the second way: openFileExtension_NotepadExample.xaml (6.9 KB)

Hope It Helps!!

Regards,

Getting error cannot find filename.file

Thank you now its working after removing .file

After opening the file i want to edit the file in particular line how to do this

Hi @sowmya
I would suggest (instead of opening the file) use Read Text File. So don’t even open it in Notepad. Read Text File will store all the text into a variable.

Then, after you Read the text you can edit and manipulate the string.

For example, if strText is the text you stored from Read Text File and lineIndex is the line you want to edit.
strText.Replace(strText.Split(vblf(0))(lineIndex),“stringlinetoReplacewith”)

There’s much you can do with this. You could google on all the various string manipulations for other suggestions.

After you have edited your text, then use Write Text File to overwrite the file.

Thanks.

EDIT: Also, you can use LINQ or ForEach to loop through lines if you want the line that you edit more dynamic, for example looking for key words. Anyway hope this info is helpful.