unable to open text file - input

I'm trying to get a program to open a file and read from it. However, I can't seem to get it to open the file. I've read several threads about this and I've seen the suggestion to make sure the file is in the same directory as my executable. I don't know how to check if that's true. The text file is saved in the same file as my program files, if that helps. Can anyone give me some input? Relevant code below. Thanks!
std::ifstream myfile;
myfile.open("../ResInput.txt", ios::in);
if(myfile.is_open()){
getline(myfile, stemp1);...

Your open() call is trying to go up one directory to read the file as it's written right now. If you want the file opened in the same directory as your executable, remove the ../ in your open() call.
This is also assuming your OS accepts a forward slash as a directory separator. It would also be useful to know the error you are getting.

Related

How do I download a file in a custom directory?

I googled it and no help. I am making a program here people register and then they can download some indie games i am creating. But i am having problems with the download function. When i go to download the game / program i am getting a error saying i need a file extension here is the code i am trying
My.Computer.Network.DownloadFile("https://www.dropbox.com/sh/yioya7ek0dq1r60/AABzT-98B4DWPdgv1edYC5SMa?dl=0", "C:\ProgramData\GamingcenterApp\games")
I need it to be like this because it is downloading a games folder that the gaming center will know it is installed so it can open the app.
Thanks GamingBlock
Let me explain what to do. DownloadFile downloads a file to your PC, and not a folder. Here is the fixed code:
My.Computer.Network.DownloadFile("C:\ProgramData\GamingcenterApp\games", "READ_ME.txt")
Folders are purposely not supposed to be downloaded by the DownloadFile call. I haven't tested your code but it could generate an exception.
Argument 1 is the file you want to download from the internet, and Arguement 2 is the file name. Not the directory you want it to download to. Also, You can't set the text in the .txt file by code. And of course this will generate an exception because I tested your code.
If this does not help, Simply comment on this answer and I will try to improve it.

How to specify LINQPAD.config file in lprun

I put my LINQPAD.config in the same folder as LINQPad.exe and it works well for LinqPad GUI.
When I run the same .linq program via lprun.exe. lprun.exe does not use the same LINQPAD.config file as LINQPad.exe but instead it expects a LINQPAD.config file in the same directory as the .linq file which is passed as an argument to lprun.exe.
This is quite inconvenient. Now, I have two options, either copy LINQPAD.config to where my .linq script is or copy my .linq script to where lprun.exe is.
lprun.exe's help doesn't mention anything about specifying a path to LINQPAD.config.
This is a bug and will be fixed for the next LINQPad 5 release (5.0.10). It should pick up the config file from the query folder only if it exists, otherwise it should fall back to the lprun.exe folder.

Xcode 'clang failed with exit code 1' error when building for test

I'm trying to build my project for test but I'm getting this error:
http://i.stack.imgur.com/K5eT5.png
I have read through all threads that I've found but nothing has helped. I have tried specifying the direct path to both the .pch and .plist files under 'build settings'.
This most likely comes up because I've duplicated my project and renamed it.
This line tells you the problem:
Check your build settings for the ".pch" file. The setting must match the actual file and path.
Try opening the file in the finder, open a new finder window, shiftcommandG and enter the file address from the build settings, you should be able to open it. Or use Terminal (you will have to quote the path in Terminal).
Beware of the spaces in the file names. I avoid spaces in file and directory names in development because they many times need to be handled in a special manner such as quoting.

Trying to create .htaccess file using ftp doesn't work

I want to create a .htaccess file in a specific directory. I'm using Notepad++ and their plug-in for FTP (NppFTP). I'm able to create any other files and see them in the folder but when I try to create a .htaccess I don't see that file in the directory. I get no errors, it is like nothing happened.
I tried to create this file using an FTP program and it showed the file and right away it disappeared. My guess it is because this is a special file used by the system and prefixed by a (.)
What is a way to edit that file?
This is probably because your ".htaccess" file is a hidden file and your system is set up to no display hidden files.
Have a look in your Notepad++ settings if there's an option to make hidden files visible/unhide.
In addition to that check the windows folder options for that option!
switch on showing hidden files in your ftp client

Intellij Idea problem with text file impossible to read

I have a problem using Intellij Idea.
I am absolutely unable to load text file as InputStream - it doesnt matter where do I put the file (main/java, main/resources...) it just can't find the file - in Eclipse everything works just fine.
I tried setings->compiler->resource patterns and added ?*.txt but that doesn't seem to work either.
Any help is appreciated.
If you load it as a File, make sure that Working Directory is properly set in IDEA Run/Debug Configuration, since it's the default directory where Java will look for a file when you try to access it like new File("file.txt"). Working directory should be set to the directory of your project containing .txt files.
If you load files as a classpath resource, then they should reside somewhere under Source root and will be copied to the classpath according to Settings | Compiler | Resource Patterns.
If you can't get it working, upload your project somewhere including IDEA project files so that we can point to your mistake.
Look at the image, notice that the txt files are in the project root, and not the source folders (in blue).
If you open the Project Structure dialog, and click on Modules and select your module - are the correct folders marked as Source Folders on the sources tab?
Link for how to get to Project Structure dialog
Also, if you print out the absolute path of that file you are trying to read, is that anywhere near where you expect it to be?
An easy way to figure out the same would be to try creating a file in the same fashion and see where it gets created in your project. You can put your input file at the same location and it should work just fine (if it doesn't, you should check your resource pattern which might be causing the file to be not copied over in the build output).
This method actually gives you the working directory of your intellij settings which is pointed out in the accepted answer. Just sharing as I had similar trouble and I figured out this way. :)