File IO Exception "The device is not ready"

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
hi,
I have developed a vb.net application for creating a csv file from database. when i run it from my system it runs perfectly but after copying files from release folder to a directory on the server it gives an error exception "The device is not ready"
Here is the code which creates a file.
<font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" size="2 <font face="Consolas" size="2 <font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 Private</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 Sub</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 CreateCSV()</font></font>
<font face="Consolas" size="2 <font face="Consolas" size="2 ***** Access the database with ODBC ****** working fine
</font></font>
filename = </font></font><font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 "myfile"</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
& mydate & </font></font><font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 ".csv"
</font></font></font>
Dim</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 csvFile
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 As</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 String</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 =
</font></font><font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 "D:ScriptsAccounts"</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
& filename
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 If</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#2b91af" size="2 <font face="Consolas" color="#2b91af" size="2 <font face="Consolas" color="#2b91af" size="2 File</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 .Exists(</font></font><font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 "D:ScriptsAccounts"</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
& filename) </font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 Then
</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#008000" size="2 <font face="Consolas" color="#008000" size="2 <font face="Consolas" color="#008000" size="2 shows message if csvFile of same name exist
</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
MsgBox(</font></font><font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 "File Exist"</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 )
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 End</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 If
</font></font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2
Dim</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 fs
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 As</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 New</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#2b91af" size="2 <font face="Consolas" color="#2b91af" size="2 <font face="Consolas" color="#2b91af" size="2 FileStream</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 (csvFile,
</font></font><font face="Consolas" color="#2b91af" size="2 <font face="Consolas" color="#2b91af" size="2 <font face="Consolas" color="#2b91af" size="2 FileMode</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 .Create,
</font></font><font face="Consolas" color="#2b91af" size="2 <font face="Consolas" color="#2b91af" size="2 <font face="Consolas" color="#2b91af" size="2 FileAccess</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 .Write)
</font></font><font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 Dim</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 s
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 As</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 New</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#2b91af" size="2 <font face="Consolas" color="#2b91af" size="2 <font face="Consolas" color="#2b91af" size="2 StreamWriter</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 (fs)
s.BaseStream.Seek(0, </font></font><font face="Consolas" color="#2b91af" size="2 <font face="Consolas" color="#2b91af" size="2 <font face="Consolas" color="#2b91af" size="2 SeekOrigin</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 .End)
</font></font><font face="Consolas" size="2 <font face="Consolas" size="2
s.WriteLine(</font></font><font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 "field1, field2, field3"</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 )
s.Close()
<font face="Consolas" size="2 <font face="Consolas" size="2
MsgBox(</font></font><font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 <font face="Consolas" color="#a31515" size="2 "file Created"</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2 )
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 End</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 If
</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 End</font></font></font><font face="Consolas" size="2 <font face="Consolas" size="2
</font></font><font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 Sub</font></font></font>
<font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 I have installed Dot net Framework 4.0 on the server because i am using Visual Studio 2010.
</font></font></font>
<font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 Any help will be appreciated.</font></font></font>
<font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 <font face="Consolas" color="#0000ff" size="2 Thanks
</font></font></font></font></font>

View the full article
 
Back
Top