freelanceprogrammers.org Forum Index » Visual Basic

File.Exist Question

View user's profile Post To page top
k_y_p_p_e_r Posted: Sun Nov 20, 2005 12:11 pm


Joined: 20 Nov 2005

Posts: 1
File.Exist Question
Hello everyone. I have just started learing visual basic .net on my
own and I have a very newbie question. I have the following code in my
program:

Dim path As String = "c: empMyTest.txt"
If File.Exists(path) Then
MessageBox.Show("This file Exists")
End If

I cannot build the project and I get the folloing error in the task
list.

Name `File` is not declared.

Can someone explain what I have wrong with this?

Thanks in advance,

Kypper
Reply with quote
Send private message
View user's profile Post To page top
keen_black_e... Posted: Sat Dec 03, 2005 6:23 pm


Joined: 03 Dec 2005

Posts: 3
File.Exist Question
Try this. Before your private sub starts include
Import System.IO.File


[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
paranjpeus Posted: Mon Dec 12, 2005 5:24 pm


Joined: 12 Dec 2005

Posts: 4
File.Exist Question
Hi,

make sure you have added Imports System.IO
at the begining of the code ...

Also please note that if you do not have sufficient permissions it
will still through false ... check file permissions please

Regards,

Amol Paranjpe



--- In VBBeginners@yahoogroups.com, "Fuzz" <jason.evans@c...> wrote:
>
> Hello everyone. I have just started learing visual basic .net on
my
> own and I have a very newbie question. I have the following code
in my
> program:
>
> Dim path As String = "c: empMyTest.txt"
> If File.Exists(path) Then
> MessageBox.Show("This file Exists")
> End If
>
> I cannot build the project and I get the folloing error in the
task
> list.
>
> Name `File` is not declared.
>
> Can someone explain what I have wrong with this?
>
> Thanks in advance,
>
> Kypper
>
Reply with quote
Send private message
View user's profile Post To page top
paranjpeus Posted: Mon Dec 12, 2005 5:28 pm


Joined: 12 Dec 2005

Posts: 4
File.Exist Question
make sure you have added code "Imports System.IO" at the begining of
the code

--- In VBBeginners@yahoogroups.com, "Fuzz" <jason.evans@c...> wrote:
>
> Hello everyone. I have just started learing visual basic .net on
my
> own and I have a very newbie question. I have the following code
in my
> program:
>
> Dim path As String = "c: empMyTest.txt"
> If File.Exists(path) Then
> MessageBox.Show("This file Exists")
> End If
>
> I cannot build the project and I get the folloing error in the
task
> list.
>
> Name `File` is not declared.
>
> Can someone explain what I have wrong with this?
>
> Thanks in advance,
>
> Kypper
>
Reply with quote
Send private message
View user's profile Post To page top
keen_black_e... Posted: Thu Dec 15, 2005 6:01 am


Joined: 03 Dec 2005

Posts: 3
File.Exist Question
Or instantiate a instance of the class as:
Dim fMyFile As System.IO.File

You think in .net you can use those names cause they are there when you type
them. Yet, the are all in the system.dll file but you must pull them from
the parent class that they belong in. For example the file class is a part
of system.io. You cannot call it from system immediately. However, it is
shown in system cause it`s a part of system. It may sound confusing but very
easy when you get comfortable with it.


[Non-text portions of this message have been removed]
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help