|
I receive the following error when trying to DirectoryInfo on a Mapped network drive.
Error in DirectoryInfo. Error: System.IO.DirectoryNotFoundException: Could not find a part of the path 'Z:\Tom\import\TxtFiles\Sub1'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption)
at System.IO.DirectoryInfo.GetFiles(String searchPattern, SearchOption searchOption)
at System.IO.DirectoryInfo.GetFiles(String searchPattern)
at DocumentShuttleService.Service1.DirectoryInfo(String sPath, String sFileSearch)
Note: The same routine works without an error on a local c: drive in the Windows Service.
Also, the same routine works without an error in a Windows Form on a mapped network drive, yet fails in the Windows Service.
Here is the Code snippet of routine.
public Boolean DirectoryInfo(string sPath, string sFileSearch)
{
try
{
Boolean bolFoundAMatch = false;
if (sPath != string.Empty)
{
DirectoryInfo di = new DirectoryInfo(sPath);
FileInfo[] rgFiles = di.GetFiles(sFileSearch);
foreach (FileInfo fi in rgFiles)
{
bolFoundAMatch = true;
}
if (bolFoundAMatch)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
catch (Exception ex)
{
sErrorMessage = "Error in DirectoryInfo. Error: " + ex.GetBaseException().ToString();
sRetStatusErrorLog = WriteInLog(sErrorMessage);
return false;
}
finally
{
}
}
|
|
|
|
|
Can you manually navigate to Z:\Tom\import\TxtFiles\Sub1?
|
|
|
|
|
Yes, I can manually navigate to Z:\Tom\import\TxtFiles\Sub1, and can also open it via the Start, Run, Open.
|
|
|
|
|
Hi,
I'm not sure about this, however maybe you only just created the Z: mapping and it does not yet apply to the Windows services. Make sure the mapping is marked persistent (there is a checkbox for that when you create it), then try a reboot. That might help. Or not. I'm curious to know this.
|
|
|
|
|
What account is the service running under? I'l willing to bet it's "Local System", in which case, it doesn't have access to the network drives you're mapping. Services have to login to Windows just like you do. Since I doubt your network allows any machines "Local System" account permissions to network shares, the service has to be told to run under an account that has access to those resources. Open the Services manager and get properties on your service. Click on the Logon tab in the dialog that comes up and tell it to use (as a test!) your account. When the service starts, it'll have access to everything you do.
|
|
|
|
|
I get the same exact error under the Windows Service, after resetting the Drive Mapping, setting the Service Log On credentials, and then re-booting.
Reset Drive mapping:
Drive Z:
Folder \\ServerName\Folder
Connect AS
Username : Domain\MyloginName
Password : ********
checked the -> Reconnect at Login (<-- Luc, Assuming this what you meant by 'mapping is marked persistent')
In Services
Service | Properties | Log On (Tab)
Log on as:
The account: Domain\MyloginName
Password : ********
|
|
|
|
|
If you map the drive in your logon session, the mapping does not carry over to the one the service is using.
The mapping would have to be done in a login script or some other persistance method.
BTW, you should not be using mapped drives in your service, rather UNC paths are preferred.
|
|
|
|
|
The UNC method worked without issue; therefore, for now I'm going to change all the components related to this process to use the UNC rather than a mapped network drive. NOTE: I will follow up with a reply post if I ever isolate why the same code works in the Windows Form but not in the Windows Service.
|
|
|
|
|
Tomb421 wrote: if I ever isolate why the same code works in the Windows Form but not in the Windows Service.
As Luc pointed out, the code works in your WinForms app because the mapping only exists in the process running the WinForms app. The mapping hasn't been defined in the process in which the service runs.
/ravi
|
|
|
|
|
In order to properly target this issue and increase and knowledge for all, please note the following.
In neither the Windows Forms application or the Windows Service Application is there every the creation for the Z: network mapping drive. This mapping was created externally during the booting of the pc and was created with the 'Reconnect at Log On' check true long before to the existence of the Windows Service.
The Windows Forms application or the Windows Service Application use the same routine 'DirectoryInfo' to check for the existence of a FileSearch based on the path passed to the routine. You can review this routine and the errror in the original posting.
Ravi, when you say 'The mapping hasn't been defined in the process in which the service runs.', where you thinking that the z: drive mapping was being dynamically created or is there something I am missing. Please clarify.
/Tom
|
|
|
|
|
Tom, see this[^] link. Let us know if it addresses the problem.
/ravi
|
|
|
|
|
I have tried all of the above and the only solution that I can find that works is by using UNC rather than drive mappings. I am good to go. Thank you for the good advice.
|
|
|
|
|
Hi,
I got 2 forms.. Form1 and Form2.
When the program is executed, Form1 is called. There is a button that will open Form2. At this point of time, Form2 will be on top of Form1. After the user closes Form2, i want form1 to show something..
But i cant find the OnFocus event.. any idea?
|
|
|
|
|
Documentation[^] shows a GotFocus event, which is probably what you want.
|
|
|
|
|
somehow, my form dont have the GotFocus event
|
|
|
|
|
I don't see how that's possible.
|
|
|
|
|
this might do what you are looking for.
Form1.Close();<br />
Form2.Show();
Or
Form2.Close()<br />
Form1.Show();
|
|
|
|
|
in WinForm every Control has a GotFocus event.
so please clarify and justify your observation.
|
|
|
|
|
i have look thru many times.. Do not have the GotFocus event..
Well, i think i create a static method in Form1 and before Form2 closes, it will fire Form1 method instead of using the GotFocus
|
|
|
|
|
benjamin yap wrote: i have look thru many times
through what?
If you can't give clear and detailed information, people won't be able to offer effective help.
|
|
|
|
|
You have one, every form that inherits from system.windows.forms.form has one.
|
|
|
|
|
Hi all,
I am trying to perform acoustic training from a wav file using SAPI 5.3. I am able to load the wav file and have it recognized and transcribed by the Speech Runtime.
Now my problem is that I want to supply a character string to the engine using the ISpTranscript interface described in the SAPI 5.3 documentation. This step is necessary in order to have the speech engine be trained from the wav file. However, when I search for it (in Visual Studio 2008 object browser) it is not there. I find a few examples of it using the interface in C++ but none using C#. According to the documentation you would use QueryInterface to instantiate the ISpTranscript object from the SpStream object. In C#, there is no method provided (Such as GetTranscript()) in the SpStream object or any of its derived classes.
Is this something that should be done in C++ in order to have it instantiate? Or am I way off the mark in trying to solve this problem. Any help or insight into this matter would be welcomed and appreciated.
I will post all the code once completed. If someone is interested in any of the functionality that I do have complete, I would be willing to share it.
|
|
|
|
|
Do you want to recognized specific words ?
Tell me more, because the Speech engine has changed a little bit. So, I will be able to help you, just let me know what do you want to do with your wave file ? Recognize some words and execute commands for instance ?
|
|
|
|
|
Thanks for your reply.
I want a user to be able to improve the speech engine's recognition capability over time. In my application I want a user to be able to start using it immediately. The user will then be able to review what the engine's output was and correct it. The application will then use the corrected text along with the original wav file to teach the speech engine to improve it's transcription ability over time for a specific user.
I hope that makes sense. Please let me know if you need some clarification.
|
|
|
|
|
In fact in C# the speech recognition is not directly based on the SAPI interface, there is an inermediate level.
This code will not help to train... !!! I didn't find the interface based on its guid (ISpTranscript) in the System.Speech
SpeechRecognitionEngine engine = new SpeechRecognitionEngine();
engine.SetInputToWaveFile("MyWaveFile.wav");
engine.LoadGrammar(new DictationGrammar());
engine.RecognizeAsync(RecognizeMode.Multiple);
engine.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(engine_SpeechRecognized);
// In order to know when the wave is finished
engine.AudioStateChanged += new EventHandler<AudioStateChangedEventArgs>(engine_AudioStateChanged);
Hope it helps...
|
|
|
|