?
Solved

Application creates files on the client not the server

Posted on 2006-11-16
12
Medium Priority
?
232 Views
Last Modified: 2010-04-16
Hello experts:

I've inherited a C# Windows application that when it runs on a server (win 2000), it works like a charm.
During the run it creates some text files on the server drive. These files are used at the end of the run to do a bulk insert into sql.

But when I run it from a client it outputs the text files not on the server drive but on the client's drive so the application has an exception during the bulk insert because it's looking for the text files on the server drive.

Has anybody heard of this and if so what I can do so that when I run the application from the client, it outputs the text files(needed for the bulkinsert) into the server drive not the clients's.

Thanks        
0
Comment
Question by:lancerxe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 

Author Comment

by:lancerxe
ID: 17961337
The path is defined at the @Application.StartupPath
0
 

Author Comment

by:lancerxe
ID: 17961450
If the @Application.StartupPath gets the path for the executable file that started the application, then that's why the text files are outputted on the server drive if the application is run from the server and are outputted on the client's drive when the application is run from the client.

How can I output the text files on the server drive when the application is run from the client's.?
I guess Application.StartupPath does not help me in this case.
0
 
LVL 22

Accepted Solution

by:
cookre earned 2000 total points
ID: 17961534
Create two path variables, one for files to reside locally, and one for files to reside on the server, say, LocalPath and ServerPath.

During program initialization, set them both to the local path, say, StartupPath, then check to see if you're running on a server or workstation.  If the former, reset ServerPath to the appropriate UNC or with a drive mapping, if one exists.
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 22

Expert Comment

by:cookre
ID: 17961550
Oops, that's 'latter', not 'former'.
0
 

Author Comment

by:lancerxe
ID: 17961575
Thanks cookre but I have a question.
Is there a way to determine from inside the code whether aplication is running on a server or workstation?
0
 

Author Comment

by:lancerxe
ID: 17961760
I found this VB6 code that may help me determine whether aplication is running on a server or workstation.
Am I on the right track ?

Private Declare Function GetSystemMetrics Lib "user32" (ByVal
nIndex As Long) As Long
Const SM_REMOTESESSION = &H1000


Function IsTerminalServicesSession() As Boolean
   Dim b As Boolean


   b = GetSystemMetrics(SM_REMOTESESSION)


   IsTerminalServicesSession = b
End Function


Example:


    If (IsTerminalServicesSession()) Then
        ' It's a Terminal Server session
    Else
        ' It's local on the user's workstation
    End If


0
 
LVL 22

Expert Comment

by:cookre
ID: 17961779
Now, why did I suspect that was coming?


This usually depends on the organization's infrastructure.

Is there a distinguishing characteristic in computer names?

Do workstations get their IPAs via DHCP and servers static?

Do workstations/servers have services/agents that servers/workstations don't (for example W3SVC (IIS))?

If there are sufficiently few servers, one can check against the actual names (poor form).

Can they be distinguished by OS version?

Can they be distinguished by drive mappings, or lack thereof?
0
 
LVL 22

Expert Comment

by:cookre
ID: 17961786
If every time it's run on a server is via a Terminal Services session, then yes.
0
 

Author Comment

by:lancerxe
ID: 17965052
Thanks cookre.
I get the idea.
0
 

Author Comment

by:lancerxe
ID: 17979940
Hello cookre:

We are almost there.

Here's what i did.

1) I use  drive mapping to acces the server path. (y:\)
2) Modified the code to output to server path  (y:\) if running from the client.
3) It works because the History.txt files is now created on the server (mapped drive y:\).

However during the BulkInsert step, I get this error:
Error [42000] [MS Sql Server Driver] [Sql server] Could not bulk insert because file y:\History.txt could not be opened. OS System error 3(system cannot find the path specified)

The error says the path cannot be found. But how come it found the path when History.txt was created on the mapped drivey:\.
Could this be a right issue?

0
 
LVL 22

Expert Comment

by:cookre
ID: 17980505
I'd guess it's just a normal file not found problem.

Alas, I don't know enough about MSSQL to give a good diagnosis, but a guess might be that the mapping to y was done on one box, a path containing y: was then passed to and executed on another box - that doesn't know what y: is.

If that's the case, passing a UNC would get around the problem.
0
 

Author Comment

by:lancerxe
ID: 17980518
Hello.
As I suspected it was a rights issue.
Everything is working  
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question