Hi I am using the Directory object in the System.IO Namespace. When I use the
following code It gives me Object reference not set to an instance of an
object. Can Anyone tell me what I am doing wrong?

The line is Direcotry.exists("C:\")


Thanks
Kiran Kumar

Re: Directory Question by Mattias

Mattias
Fri Mar 25 12:50:20 CST 2005

>Hi I am using the Directory object in the System.IO Namespace. When I use the
>following code It gives me Object reference not set to an instance of an
>object. Can Anyone tell me what I am doing wrong?
>
> The line is Direcotry.exists("C:\")


Please post a complete code snippet that reproduces the error you're
getting.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Re: Directory Question by KiranKumarPinjala

KiranKumarPinjala
Fri Mar 25 12:59:01 CST 2005

Hi, Here it is, When I use this in a normal application it works, But I am
writing a windows service, that gets files from a particular directory. It
works on some machines and does not work fine on others like the
Pre-Production server, which is identical to the Integration server.

IF (Directory.Exists("C:\") THEN
'Do Some stuff Here
Else
'Do Some other stuff here.
End If

Thanks
Kiran

"Mattias Sjögren" wrote:

> >Hi I am using the Directory object in the System.IO Namespace. When I use the
> >following code It gives me Object reference not set to an instance of an
> >object. Can Anyone tell me what I am doing wrong?
> >
> > The line is Direcotry.exists("C:\")
>
>
> Please post a complete code snippet that reproduces the error you're
> getting.
>
>
>
> Mattias
>
> --
> Mattias Sjögren [MVP] mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.
>

Re: Directory Question by Scott

Scott
Fri Mar 25 14:11:30 CST 2005

You must make an instance of the "directory" class before you can use it.

Dim theDirectory As New Directory
If theDirectory.Exists("c:/") Then....



"Kiran Kumar Pinjala" <KiranKumarPinjala@discussions.microsoft.com> wrote in
message news:DACB717C-6121-4134-AC0C-2DF3F2A9DD4F@microsoft.com...
> Hi, Here it is, When I use this in a normal application it works, But I am
> writing a windows service, that gets files from a particular directory. It
> works on some machines and does not work fine on others like the
> Pre-Production server, which is identical to the Integration server.
>
> IF (Directory.Exists("C:\") THEN
> 'Do Some stuff Here
> Else
> 'Do Some other stuff here.
> End If
>
> Thanks
> Kiran
>
> "Mattias Sjögren" wrote:
>
>> >Hi I am using the Directory object in the System.IO Namespace. When I
>> >use the
>> >following code It gives me Object reference not set to an instance of an
>> >object. Can Anyone tell me what I am doing wrong?
>> >
>> > The line is Direcotry.exists("C:\")
>>
>>
>> Please post a complete code snippet that reproduces the error you're
>> getting.
>>
>>
>>
>> Mattias
>>
>> --
>> Mattias Sjögren [MVP] mattias @ mvps.org
>> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
>> Please reply only to the newsgroup.
>>



Re: Directory Question by Mattias

Mattias
Fri Mar 25 15:54:10 CST 2005


>Hi, Here it is

I doubt it...

> IF (Directory.Exists("C:\") THEN

This doesn't even compile since you're missing a closing parenthesis.

If you don't post your actual code, it's hard to guess what's causing
the exception. From what you've described so far, we don't know for
sure if it actually is the Exists call that fails or if it is some
code before or after it. Please post something that's complete enough
to compile.

http://www.yoda.arachsys.com/csharp/complete.html



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.