|
The Error:
Could not find file "\\myserver\share$\myfile.txt".
The Code:
File.Copy(@"\\myserver\share$\myfile.txt",@"c:\myfile.txt"), true);
The file is there. The premissions on the share$ is set to everyone. I can navigate to the file using the above quoted string. What am I missing?
|
|
|
|
|
|
Hi!
I guess the problem lies in the share itself.
If you enter "\\myserver\share$" in the address bar of a windows explorer, do you get a dialog asking for a user name and password?
If you can see the file in your explorer, does the program still throw the exception afterwards?
Or is the code executed from within a windows service process running under LocalSystem account?
mav
|
|
|
|
|
thank you for responding...
no.. no dialog box appears. Any lowly person in the company and open this share no problem.
And the code is being executed by ASPNET account
|
|
|
|
|
i think i've boiled down the issue. ASPNET service account is a local service account to my machine. I'm trying to copy a file from a domain server. The premissions on the server is set to everyone, but that means everyone in the Domain, not local mcahin accounts. Now I need to figure out how to pass premissions with my file.copy... any clues?
|
|
|
|
|
You don't.
You can create a domain account, restrict it's log to certain machines!, that the ASP.NET server can run under. It doesn't have to run under a local machine account!
Then you can give that domain account appropriate rights to the machines and folders required to run your code and do file copies.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Maybe the parameter are incorrect you can try with the ip:
File.Copy(@"\###.###.###.###\directory\file.txt",@"c:\file.txt",true);
I can use the instruction like my example and work well.
|
|
|
|
|
Hi,
I will retrive a lot of data from database into a datatable and display these records into user interface as a datagrid or datarepeater. The problem is the data has to be retrived again from database every time when I want to narrow down the search result or even just go to different pages of the datarepeater.
Is there anyway to save the table records so that I can use the data dirctly instead of connect to sql server everytime. I dont want to save it into a session, coz it could be expired anytime.
Thanks.
|
|
|
|
|
Hi there,
There are some options come to mind, IMO:
- using cache mechanism
- using export the datatable to temporary xml file
<< >>
|
|
|
|
|
Create a DataView from the DataTable, and display that. apply filters, page selection logic to the datatable to create the dataview.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
I thinking caching is the best alternative to ur problem. U can then also set dependency with ur database. By that way if in the meanwhile database had been modified, u can know it as ur cache will get empty....
Regards,
Sandeep
+919891027854
|
|
|
|
|
I have a DataSet that contains a table "results" which is popuated with data from a database.
I need to know the number of rows in the "results" table. Is there a simple way to grab this information? A property or some such? Thanks.
|
|
|
|
|
DataSet.Tables[0].rows.count
|
|
|
|
|
|
Wouldn't DataSet.Tables["tablename"].Rows.Count be more appropriate? Just in case that table is not #0 in the list?
|
|
|
|
|
|
|
Hi All.
I writing some application and in it i wrote some Log file that will be as instance in each class and in each class that use the log - will able to send string to the log file.
I have some problem that create some exception in my log file.
In log class i have method call "Write" that getting string and writing it to file.
In the end of method "Write" the log class close the file by doing this line
if (m_cFileStream!= null)
m_cFileStream.Close();
After i call the "Write" class again i getting Exception in the line that do :
StreamWriter cStreamWrite = new StreamWriter(m_cFileStream);
[The variable m_cFileStream is not a null and he hold the same information they were in it before calling the block that close the FileStream]
I realy dont understand why i getting an exception and how to solve this problem.
Someone can Help me ??
|
|
|
|
|
The problem is that when you call c_fileStream.Close() you are in essence destroying this object. Stream.Close ends up mappnig to Stream.Dispose(). You'll either have to create a new instance of the stream class or not destroy it the first time.
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
Jared you nailed it!
Yanshof here is some design info for ya:
When designing a Logger application here is a basic strategy to employ in your architecture. Note I highly recommend using the Async architecture to keep you application running efficiently instead of blocking all over the place. That means Stream::BeginRead, Stream::EndRead, Stream::BeginWrite, Stream::EndWrite for your cStreamWriter object, as well as Socket::BeginAccept, Socket::EndAccept, Socket::BeginReceive, and Socket::EndReceive for your socket or network stream objects.
At any rate:
Startup sequence:
Open the log file. This includes the necessary checks to determine if it exists, needs to be created, or pehaps is too large and needs to be replaced, etc. The key here is once you get the file open you need to keep it open and preserve the file stream until you are ready to shutdown or encounter a recoverable exception and restart. Also whatever stragey you employ for archiving log files and naming log files should be considered part of startup as well as part of some event based trigger, e.g, midnight, file size exceeds 1MB, etc.
Incoming Log Requests:
Decode the message, format the message, write it to the log file. Since we're talking I/O make sure you are using Try/Catch blocks in the event your file stream goes south suddenly. And here is where you would start the write with the m_cFileStream.BeginWrite() call. When the write completes the underlying driver tickles the CLR which in turn posts an IAsyncResult to your End???? handler.
A note about flushing the cache. If there is any need to flush the cache instead of leaving it up to the OS, then you should employ your threshold for flushing here. For example after every 100 messages you decide. That said there is no real need unless you can come up with one.
Timer or Event based Action:
As noted your Logger should worry about file size and rollover. Based on some timer firing, some file size grown past its threshold, or whatever, your application should take this into account. Since your application should be Async I do NOT recommend doing this in a While loop in the mainline code.
Shutdown Sequence:
OK, Here is where you close the sockets and lastly the file. In otherwords, this is the appropriate place to be calling m_cFileStream.Close(). Before you do that however make sure all client connections and Shutdown and Closed first.
Async vs. Threads
In this reponse I have advocated the Async model. But if you enjoy the threaded approach you can definitely implement a logger that way too. Suffice to say its another can of worms though.
Good Luck with it!
Mike
|
|
|
|
|
i need an API for Information Extraction (from text)
in C#.
if somebody can help me and send me some references about it
For example for Java there is a software called Extractor.
i hope somebody will help me
thhank you all
eyalso
|
|
|
|
|
Java Extractor is an unzipping application.
Is that what you are after, or are you looking for a Regex (find/sort text in text") approach ?
|
|
|
|
|
hi
i am looking for Regex (find/sort text in text") approach
in C#
eyalso
|
|
|
|
|
|
Not sure if this should be here or in the C# forum but here goes. I want to create an out-of-process COM component (like an ActiveX exe in VB6) in C# - does anybody know how to do this? I've created in-process COM component with no problems. Any ideas/links would be most appreciated.
Cheers
|
|
|
|