Jump to content

Some help with C# program?

Go to solution Solved by gastew15,

What the program does is it has buttons that will open some Word documents that'll be on the same folder as the program, the problem is for it to work I need to supply Word with a path to the file, something like: "C:\Users\username\Downloads\Program_Folder\WordDocs\document.docx", but I need a way of not needing to "guess" the username of who will use it so it works, did that clear things up for you?

This here will let you have access to the to the current users downloads folder

<Code>

string pathUser = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

string pathDownload = Path.Combine(pathUser, "Downloads");

</Code>

Hi!

 

So, I've been learning C# and I wanted to do something that's been on my mind for a while. It's a pretty simple program, all it does really is open some word documents, it basically works as a launcher for a specific collection of documents. The documents are some forms that one of my teachers gave us and she wanted those documents to be like a portfolio of sorts, so she actually did a html page that had buttons to the files and it kinda worked, but there was a problem, when you clicked the buttons it would basically copy the original form to the downloads folder instead of opening it, so if you clicked a button to open the file on the html page, made some changes, saved the changes and then tried to see the altered file by using the html button it wouldn't work, since it would alwas copy a new un-altered form to the downloads folder and open it, and not open the altered form.

I then decided that I would try to make a more elegant solution, one that would alwas work and not only work as a glorified copy button. This all was almost a year ago, and since I didn't really know how to code in anything but html and I wanted to do a "real" program I put it on hold, I also tried doing it in VB when I watched some tutorials on it but school got in the way and I forgot about it until now. I decided to try it again now because I've been watching Barnacules Coding tutorials and in the last one he showed how to open a program using C#. (he is using console applications but I decided to use a forms one since I already had some experience with VB forms and I want people in my class to use it). 

I'm almost done, it's working just fine on my machine but there is a problem, file paths, I can make them work on my machine, but I can't possibly guess the paths for every single computer that will use the program. Is there anyway for me to go around this issue?

 

Thanks in advance!

i'm a potato

Link to comment
https://linustechtips.com/topic/205165-some-help-with-c-program/
Share on other sites

Link to post
Share on other sites

-Snip-
file paths, I can make them work on my machine, but I can't possibly guess the paths for every single computer that will use the program. Is there anyway for me to go around this issue?

 

Hello, I have a couple solutions for you, but first so I can narrow them down I'd like to ask what exactly you mean by that. My question would be if you want a folder browser and have the user select which folder they want to work in, or do you just want a hardcode value that will always goto say, my documents for example?

"Her tsundere ratio is 8:2. So don't think you could see her dere side so easily."


Planing to make you debut here on the forums? Read Me First!


unofficial LTT Anime Club Heaven Society

Link to comment
https://linustechtips.com/topic/205165-some-help-with-c-program/#findComment-2785391
Share on other sites

Link to post
Share on other sites

Hello, I have a couple solutions for you, but first so I can narrow them down I'd like to ask what exactly you mean by that. My question would be if you want a folder browser and have the user select which folder tey want to work in, or do you just want a hardcode value tat will always goto say, my documents for example?

 

What the program does is it has buttons that will open some Word documents that'll be on the same folder as the program, the problem is for it to work I need to supply Word with a path to the file, something like: "C:\Users\username\Downloads\Program_Folder\WordDocs\document.docx", but I need a way of not needing to "guess" the username of who will use it so it works, did that clear things up for you?

i'm a potato

Link to comment
https://linustechtips.com/topic/205165-some-help-with-c-program/#findComment-2785419
Share on other sites

Link to post
Share on other sites

What the program does is it has buttons that will open some Word documents that'll be on the same folder as the program, the problem is for it to work I need to supply Word with a path to the file, something like: "C:\Users\username\Downloads\Program_Folder\WordDocs\document.docx", but I need a way of not needing to "guess" the username of who will use it so it works, did that clear things up for you?

This here will let you have access to the to the current users downloads folder

<Code>

string pathUser = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

string pathDownload = Path.Combine(pathUser, "Downloads");

</Code>

"Her tsundere ratio is 8:2. So don't think you could see her dere side so easily."


Planing to make you debut here on the forums? Read Me First!


unofficial LTT Anime Club Heaven Society

Link to comment
https://linustechtips.com/topic/205165-some-help-with-c-program/#findComment-2785460
Share on other sites

Link to post
Share on other sites

This here will let you have access to the to the current users downloads folder

<Code>

string pathUser = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

string pathDownload = Path.Combine(pathUser, "Downloads");

</Code>

 

Thank you! I'll test it and I'll get back to you in a bit to tell you if it worked!

i'm a potato

Link to comment
https://linustechtips.com/topic/205165-some-help-with-c-program/#findComment-2785477
Share on other sites

Link to post
Share on other sites

This here will let you have access to the to the current users downloads folder

<Code>

string pathUser = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

string pathDownload = Path.Combine(pathUser, "Downloads");

</Code>

 

I got this error: The name 'Path' does not exist in the current context

 

on:

string pathDownload = Path.Combine(pathUser, "Downloads");

i'm a potato

Link to comment
https://linustechtips.com/topic/205165-some-help-with-c-program/#findComment-2785497
Share on other sites

Link to post
Share on other sites

 

I got this error: The name 'Path' does not exist in the current context

-Snip-

 

add "using System.IO;" above the namespace with the other usings

"Her tsundere ratio is 8:2. So don't think you could see her dere side so easily."


Planing to make you debut here on the forums? Read Me First!


unofficial LTT Anime Club Heaven Society

Link to comment
https://linustechtips.com/topic/205165-some-help-with-c-program/#findComment-2785512
Share on other sites

Link to post
Share on other sites

So I'm guessing you got it to work then?

"Her tsundere ratio is 8:2. So don't think you could see her dere side so easily."


Planing to make you debut here on the forums? Read Me First!


unofficial LTT Anime Club Heaven Society

Link to comment
https://linustechtips.com/topic/205165-some-help-with-c-program/#findComment-2785963
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×