VS C# 2008 SP1mciSendString은 디렉터리 경로에 저장할 수 없습니다.
오디오를 녹음하고 재생하는 작은 응용 프로그램이 있습니다. 그러나, 내 응용 프로그램은 웨이브 파일을 사용자 컴퓨터의 응용 프로그램 데이터 디렉토리에 저장해야합니다.
mciSendString은 C 스타일 문자열을 매개 변수로 사용하며 8.3 형식이어야합니다. 그러나 내 문제는 그것을 구할 수 없다는 것입니다. 이상한 것은 때로는 때로는 때로는 때로는 그렇지 않습니다. Howver, 대부분의 시간은 실패입니다. 그러나 C 드라이브에 직접 저장하면 처음에는 모든 것이 작동합니다. 아래에 코딩 한 3 가지 방법을 사용했습니다. 나는 그것이 실패했을 때 얻을
오류 번호는 "당신의 시스템에 충분한 디스크 공간이 있는지 확인합니다. 파일이 저장되지 않았거나 손상되지 않은 네트워크 연결이"286 어떤 suggestins에 대한
많은 감사,
을[DllImport("winmm.dll",CharSet=CharSet.Auto)]
private static extern uint mciSendString([MarshalAs(UnmanagedType.LPTStr)] string command,
StringBuilder returnValue,
int returnLength,
IntPtr winHandle);
[DllImport("winmm.dll", CharSet = CharSet.Auto)]
private static extern int mciGetErrorString(uint errorCode, StringBuilder errorText, int errorTextSize);
[DllImport("Kernel32.dll", CharSet=CharSet.Auto)]
private static extern int GetShortPathName([MarshalAs(UnmanagedType.LPTStr)] string longPath,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath,
int length);
// Stop recording
private void StopRecording()
{
// Save recorded voice
string shortPath = this.shortPathName();
string formatShortPath = string.Format("save recsound \"{0}\"", shortPath);
uint result = 0;
StringBuilder errorTest = new StringBuilder(256);
// C:\DOCUME~1\Steve\APPLIC~1\Test.wav
// Fails
result = mciSendString(string.Format("{0}", formatShortPath), null, 0, IntPtr.Zero);
mciGetErrorString(result, errorTest, errorTest.Length);
// command line convention - fails
result = mciSendString("save recsound \"C:\\DOCUME~1\\Steve\\APPLIC~1\\Test.wav\"", null, 0, IntPtr.Zero);
mciGetErrorString(result, errorTest, errorTest.Length);
// 8.3 short format - fails
result = mciSendString(@"save recsound C:\DOCUME~1\Steve\APPLIC~1\Test.wav", null, 0, IntPtr.Zero);
mciGetErrorString(result, errorTest, errorTest.Length);
// Save to C drive works everytime.
result = mciSendString(@"save recsound C:\Test.wav", null, 0, IntPtr.Zero);
mciGetErrorString(result, errorTest, errorTest.Length);
mciSendString("close recsound ", null, 0, IntPtr.Zero);
}
// Get the short path name so that the mciSendString can save the recorded wave file
private string shortPathName()
{
string shortPath = string.Empty;
long length = 0;
StringBuilder buffer = new StringBuilder(256);
// Get the length of the path
length = GetShortPathName(this.saveRecordingPath, buffer, 256);
shortPath = buffer.ToString();
return shortPath;
}
감사합니다. 시험해 보겠습니다. – ant2009