6 Replies - 370 Views - Last Post: 20 June 2012 - 07:23 AM Rate Topic: -----

#1 edkinss  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-June 12

System.IO.File has no methods

Posted 19 June 2012 - 07:35 PM

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
Is This A Good Question/Topic? 0
  • +

Replies To: System.IO.File has no methods

#2 Kilorn  Icon User is offline

  • XNArchitect
  • member icon




Reputation: 1325
  • View blog
  • Posts: 3,504
  • Joined: 03-May 10

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

Was This Post Helpful? 0
  • +
  • -

#3 racidon  Icon User is offline

  • D.I.C Head

Reputation: 59
  • View blog
  • Posts: 172
  • Joined: 27-August 11

Re: System.IO.File has no methods

Posted 19 June 2012 - 09:19 PM

View PostKilorn, 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.
Was This Post Helpful? 0
  • +
  • -

#4 MrShoes  Icon User is offline

  • D.I.C Regular

Reputation: 186
  • View blog
  • Posts: 303
  • Joined: 13-June 12

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.
Was This Post Helpful? 0
  • +
  • -

#5 edkinss  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-June 12

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
Was This Post Helpful? 0
  • +
  • -

#6 tlhIn`toq  Icon User is offline

  • Closing in on 5,000
  • member icon

Reputation: 4928
  • View blog
  • Posts: 10,465
  • Joined: 02-June 10

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.
Was This Post Helpful? 1
  • +
  • -

#7 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1511
  • View blog
  • Posts: 5,916
  • Joined: 21-March 08

Re: System.IO.File has no methods

Posted 20 June 2012 - 07:23 AM

To expand on what tlhIn`toq posted....

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.
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1