I am using VS 2010 Express on Windows 7. In a file manipulation project, with Using System.IO, any code line I type with System.IO.File stops there - no further intellisense help. It's like all the File methods are gone, so I can't do anything with the File class. Have I missed something obvious (or obscure) in my setup or references? Any ideas?
Thanks in advance,
Simon
System.IO.File has no methods
Page 1 of 16 Replies - 370 Views - Last Post: 20 June 2012 - 07:23 AM
Replies To: System.IO.File has no methods
#2
Re: System.IO.File has no methods
Posted 19 June 2012 - 07:43 PM
Did you actually add the reference to the project? As in right click the project in the solution explorer and choose add reference? Or did you just slap in a using statement? New projects do not include the System.IO namespace, or any namespace under it by default. You will have to add the proper reference(s) before you can actually use anything from it.
This post has been edited by Kilorn: 19 June 2012 - 07:43 PM
#3
Re: System.IO.File has no methods
Posted 19 June 2012 - 09:19 PM
Kilorn, on 19 June 2012 - 07:43 PM, said:
Did you actually add the reference to the project? As in right click the project in the solution explorer and choose add reference? Or did you just slap in a using statement? New projects do not include the System.IO namespace, or any namespace under it by default. You will have to add the proper reference(s) before you can actually use anything from it.
I've never add reference to this, I've only had to input the using statement. Perhaps you use a professional edition of Visual Studio? Where as I use C# Express (as does the OP), I do however have to put in reference for stuff from VB for example.
#4
Re: System.IO.File has no methods
Posted 20 June 2012 - 12:06 AM
I've found with Express you usually get the common references added automatically when you create a solution, but sometimes you need to add them manually. Just yesterday I had to add a reference to System.Data.SqlServerCE even though it's normally just there.
#5
Re: System.IO.File has no methods
Posted 20 June 2012 - 05:27 AM
When I bring up the Add Reference dialog, System.IO is not listed, so I assume it is already referenced. The nearest thing is System.IO.log, which I doubted would work but tried it anyway - it doesn't help.
I should add that this occurs on two different machines, both running the same OS and VS version.
Simon
I should add that this occurs on two different machines, both running the same OS and VS version.
Simon
#6
Re: System.IO.File has no methods
Posted 20 June 2012 - 05:53 AM
You can't reference a framework method at CLASS level.
Make sure you are trying to use it within one of your own methods.
If you aren't in the habit of cleaning up indentation etc. it can easily get messy.
Hit control-k control-d (Klean Document) to have your code document cleaned up, alignment fixed and so on.
Make sure you are trying to use it within one of your own methods.
If you aren't in the habit of cleaning up indentation etc. it can easily get messy.
Hit control-k control-d (Klean Document) to have your code document cleaned up, alignment fixed and so on.
#7
Re: System.IO.File has no methods
Posted 20 June 2012 - 07:23 AM
To expand on what tlhIn`toq posted....
Notice that you need to be in a method, property, constructor, etc. for the methods/properties of a class to show up. If you are outside of those, the properties/methods will not show up.
public class MyFileClass
{
//this will not show the methods
System.IO.File.[nothing shows]
public Stream GetFile(string path)
{
//methods will show here...
System.IO.File.Exists(path);
}
}
Notice that you need to be in a method, property, constructor, etc. for the methods/properties of a class to show up. If you are outside of those, the properties/methods will not show up.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote









|