Question: Well I've been trying to read a .cso file to use as a shader for a DirectX program I'm currently making.

Problem is no matter how I implemented a way to read the file it never worked. And after fidgeting around I discover that it's only the .cso files I can't read.

I can read anything else (which means it works) even their .hlsl files. Which is strange because the .hlsl (high level shader language) files are supposed to turn into .cso (compiled shader object) files.

What I'm currently doing is:

```
vector<byte> Read(string File){
    vector<byte> Text;
    fstream file(File, ios::in | ios::ate | ios::binary);

    if(file.is_open()){
        Text.resize(file.tellg());
        file.seekg(0 , ios::beg);
        file.read(reinterpret_cast<char*>(&Text[0]), Text.size());
        file.close();
    }        

    return Text;
};

```

If I then implement it.

```
Read("VertexShader.hlsl"); //Works
Read("VertexShader.cso"); //Doesn't Works?!?!

```

And I need the .cso version of the shader to draw my sexy triangles. Without it my life and application will never continue and I have no idea what could be wrong.

(I've also asked this at stack overflow but still no answers.)

Answer: 
Depending on how you've set up your project, you likely have your .cso files going to the project output `$(OutDir)`, and your debug working directory set to the project directory `$(ProjectDir)`. As a result, file paths are relative to the project directory. You should change your working directory to the output directory for debugging, and you should be able to load the .cso files.

![Working Directory](https://i.stack.imgur.com/noQrE.png)

Note that this will cause loading your .hlsl files to *stop* working though, unless you copy them to the output directory as well (but you shouldn't need them there if you're compiling at build-time).
Can be multiple things, don't have access to VS right now to give you exact answer but it can be:

* VS shader compiler is not attached to your project. Right click on project-> build customization and check the list
* shader file is not acctually set as shader file. Right click on shader file in your project and make sure it has selected shader type and properties
* by default VS will compile your hlsl files into cso files before it compiles your main project and put them in //debug or //release, make sure you search in the right directory