Search code examples
c#visual-studio-2010msbuildcsc

CSharp compiler can't open files in parent directory


I'm trying to compile a cs file that is in a sibling directory of my project but csc fails to open it. Here's a sample of the command line that triggers the issue:

csc ../test/file.cs

Csc prints this message:

error CS1504: Source file '<path to current dir>\file.cs' could not be openned

The really really strange thing is that it strips the "../test" part.

Anyone has an idea on how to make this work? thanks


Solution

  • Since this is the command line, you should use backslashes to delimit the directories.

    csc ..\test\file.cs
    

    (In a C# program, it wouldn't matter if you'd use backslashes or forward slashes.)