• Why are men the worst gender then women?

    Best answer: They commit the majority of the violence in the world.
    Best answer: They commit the majority of the violence in the world.
    8 answers · 22 hours ago
  • C# how do I create a code for folder location?

    Best answer: Some upvoted misinformation here. (Chris's answer is good, as usual.) If you are going to distribute a copy of an application, and that application needs external files as "resources" (like sound, images, databases, external text, etc.) then you need to include those files along with the executable;... show more
    Best answer: Some upvoted misinformation here. (Chris's answer is good, as usual.)

    If you are going to distribute a copy of an application, and that application needs external files as "resources" (like sound, images, databases, external text, etc.) then you need to include those files along with the executable; and find a way to put them someplace where your program can find them when it runs. That's part of what's called "installing" a program.

    The program certainly can't read from drive D: on your computer, when it's running on another computer altogether. With C#, it might not even be on a Windows system at all. The Mono platform is now supported (and sponsored!) by Microsoft.

    The simplest approach fix this is Chris's suggestion. Put them in the same directory as the executable. One easy way to do this is to pack all of the needed files in to a ZIP archive file that will keep all files together.

    Where Windows (or Linux, MacOS, etc.) looks for files by default is not as simple as suggested. It depends on how the program is launched. The default location when run by double-clicking an icon in the file explorer (or on the desktop) is to use the same location as the exe file. That's what Chris is assuming.

    If you run from a Command Prompt or terminal window, it uses the current Windows default drive and path. If you make a Windows shortcut ("icon") to the executable file, that can point to any directory you like as the "startup directory". If you want to handle this situation gracefully, you can use a few standard .NET tools.

    To get the full path and file name to the current running program:

    string ExeFileName = System.Reflection. Assembly.GetEntryAssembly().Location;

    To get just the directory name from that:

    string ExePath = System.IO.Path. GetDirectoryName(ExePath);

    Now you can open (ExePath + "\\file.wav") as the name of the file containing the sound. Don't forget the \ separator (doubled as \\ to get a single \ in the string.)

    Windows exe files can contain resources, and there's a hint about how to do that with a sound file here:
    https://stackoverflow.com/questions/14491431/playing-wav-file-with-c-sharp

    If you're using an Express version of Visual Studio, you might have to "upgrade" to the Community edition to get full support for resources.

    A few things from earlier answers:
    Windows does NOT use any environment variables to find directories of data files. There's a PATH variable for finding executable programs when no directory was specified, but that's about it.

    There is no "current directory" entry in the environment...not one set and managed by Windows, anyway. Command Prompt adds multiple fake environment variables, such as PROMPT, TIME, ERRORLEVEL and others, includiding CD for the command processors current drive and directory. The can be used at the command line or in batch files, but are internal to the command processor and not visible to running programs.
    5 answers · 1 day ago
  • JavaScript?

    Write a function named "get_length" that takes a list as a parameter and returns the number of elements in the list
    Write a function named "get_length" that takes a list as a parameter and returns the number of elements in the list
    4 answers · 19 hours ago
  • Can someone tell me what this coding means?

    96813e3dd08933ece5b7c767a818d3be323b5af8...
    96813e3dd08933ece5b7c767a818d3be323b5af8...
    9 answers · 1 week ago
  • I need Word program?

    8 answers · 1 week ago
  • How to start getting into video game programming?

    I’m 23 and have finally found myself in a position where I’d like to peruse something I’d love to do but I don’t know exactly where to start. I always loved the idea of programming video games (understanding it’s a competitive field) was wondering if anybody had advise on where I should get started
    I’m 23 and have finally found myself in a position where I’d like to peruse something I’d love to do but I don’t know exactly where to start. I always loved the idea of programming video games (understanding it’s a competitive field) was wondering if anybody had advise on where I should get started
    6 answers · 1 week ago
  • Is coding really difficult to do?

    20 answers · 2 weeks ago
  • Write an algorithm and draw a flowchart?

    Write an algorithm and draw a flowchart that will input unknown number of data where the last number of the data is -999. This algorithm/flowchart should find and output the sum of positive numbers.
    Write an algorithm and draw a flowchart that will input unknown number of data where the last number of the data is -999. This algorithm/flowchart should find and output the sum of positive numbers.
    3 answers · 1 week ago
  • Is programming the future of most jobs?

    Best answer: yes
    Best answer: yes
    14 answers · 2 weeks ago