473,508 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.InvalidCastException error...

Hello all and thanks in advance,

I'm running a vb.net program and part of it copies files
from one server to another.

It generally works fine but once in a while I get this
error:

System.InvalidCastException: QueryInterface for interface
Scripting.IFileSystem3 failed.
at Scripting.FileSystemObjectClass.FolderExists(Strin g
FolderSpec)
the line it fails at looks like this:

If fso.FolderExists(srcDir2) Then
....
End IF

Could some one please give me some insight as to why this
error keeps poping up.

Thanks,
Michael

Nov 19 '05 #1
2 4702
"Michael" <mi*****@hotmail.com> wrote in message
news:0d****************************@phx.gbl...
Hello all and thanks in advance,

I'm running a vb.net program and part of it copies files
from one server to another.

It generally works fine but once in a while I get this
error:

System.InvalidCastException: QueryInterface for interface
Scripting.IFileSystem3 failed.
at Scripting.FileSystemObjectClass.FolderExists(Strin g
FolderSpec)
the line it fails at looks like this:

If fso.FolderExists(srcDir2) Then
...
End IF

Could some one please give me some insight as to why this
error keeps poping up.

Thanks,
Michael


Am I missing something or are you still using the Scripting COM objects? If
you are, you should really consider using the System.IO namespace. It will
be much easier.

Jeremy

Nov 19 '05 #2
Michael
It is preferable to use the methods in File and Directory classes of
System.IO to manipulate files, rather than using scripting (ie.
FileSystemObject)
eg
Imports System.IO
If Directory.Exists("...") Then
.....
End If

Stephen

"Michael" <mi*****@hotmail.com> wrote in message
news:05****************************@phx.gbl...
-----Original Message-----
"Michael" <mi*****@hotmail.com> wrote in message
news:0d****************************@phx.gbl...
Hello all and thanks in advance,

I'm running a vb.net program and part of it copies files
from one server to another.

It generally works fine but once in a while I get this
error:

System.InvalidCastException: QueryInterface for interface Scripting.IFileSystem3 failed.
at Scripting.FileSystemObjectClass.FolderExists (String FolderSpec)
the line it fails at looks like this:

If fso.FolderExists(srcDir2) Then
...
End IF

Could some one please give me some insight as to why this error keeps poping up.

Thanks,
Michael


Am I missing something or are you still using the

Scripting COM objects? If
you are, you should really consider using the System.IO

namespace. It will
be much easier.

Jeremy

.


I am using the System.IO namespace....
This error shows up in a
try...
catch e As exception ...
end try

statement.

Also fso is set as a New FileSystemObject

Michael

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8213
by: karunakar | last post by:
Hi All Here iam getting this Error "Specified cast is not valid." My Project has Onc solution diffrent class libarary In that solution DALfactory solution iam getting this error I was calling...
1
4839
by: Hifni Shahzard | last post by:
Hi, I got a stored procedure, where it returns a value. But if I execute it. It gives an error as "Invalid cast from System.Int32 to System.Byte.". To make clear how do I execute this, below I'm...
4
2647
by: DOTNET | last post by:
Hi, Anybody help me regarding this error: I am assigning the values to the session variables when the button is clicked and passing these session variables to the next page and when I am...
1
18135
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it...
2
13542
by: John Smith | last post by:
I'm writing webervice client using .Net 2.0. I have this class: public class MyWebService : SoapHttpClientProtocol { public XmlDocument validate(string url, XmlDocument xmlDocument) {...
1
5143
by: Ratz | last post by:
Hello everyone! I'm new to this Forum! I've spent about 56 hours trying to solve a .NET VB Runtime error while Using a program.Ive contacted the developer of the program and he could not figure out...
8
4247
by: Gamma | last post by:
I'm trying to inherit subclass from System.Diagnostics.Process, but whenever I cast a "Process" object to it's subclass, I encounter an exception "System.InvalidCastException" ("Specified cast is...
4
1833
by: rsdev | last post by:
Hi, I have an InvalidCastException which is completely puzzling me. I have checked all the members in the stored procedure against my data provider and seems to be ok. Also in the stack trace it...
2
2488
by: thithi | last post by:
Server Error in '/Assignment' Application. -------------------------------------------------------------------------------- Specified cast is not valid. Description: An unhandled exception...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.