Click here to Skip to main content
15,887,350 members
Home / Discussions / C#
   

C#

 
AnswerRe: Drawing a dynamic rectangle with GraphicsPath Pin
Ravi Bhavnani19-Jul-09 5:54
professionalRavi Bhavnani19-Jul-09 5:54 
QuestionFilling Enum Values?? Pin
Muammar©18-Jul-09 10:56
Muammar©18-Jul-09 10:56 
AnswerRe: Filling Enum Values?? Pin
PIEBALDconsult18-Jul-09 11:36
mvePIEBALDconsult18-Jul-09 11:36 
GeneralRe: Filling Enum Values?? Pin
Muammar©19-Jul-09 0:58
Muammar©19-Jul-09 0:58 
GeneralRe: Filling Enum Values?? Pin
PIEBALDconsult19-Jul-09 4:23
mvePIEBALDconsult19-Jul-09 4:23 
Questionc# DirectShow udp Pin
Maxim Rubchinsky18-Jul-09 10:27
Maxim Rubchinsky18-Jul-09 10:27 
AnswerRe: c# DirectShow udp Pin
ZainGhani22-Oct-11 17:51
ZainGhani22-Oct-11 17:51 
QuestionmciSendString cannot save wave file Pin
Steve1_rm18-Jul-09 6:42
Steve1_rm18-Jul-09 6:42 
Hello,

VS 2008 SP1

I have a created a small application that records and plays audio. However, my application needs to save the wave file to the application data directory on the users computer.

The mciSendString takes a C style string as a parameter and has to be in 8.3 format. However, my problem is I can't get it to save. And what is strange is sometime it does and sometimes it doesn't. However, most of the time it failes. However, if I save directly to the C drive it works first time everything. I have used 3 different methods that I have coded below.

The error number that I get when it fails is 286."The file was not saved. Make sure your system has sufficient disk space or has an intact network connection"



[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;
        }

QuestionPrintable DataGrid Pin
danishkhawar18-Jul-09 6:23
danishkhawar18-Jul-09 6:23 
AnswerRe: Printable DataGrid Pin
Gary Stafford18-Jul-09 14:57
Gary Stafford18-Jul-09 14:57 
QuestionDisplay image in table Pin
nudma18-Jul-09 5:10
nudma18-Jul-09 5:10 
AnswerRe: Display image in table Pin
dan!sh 18-Jul-09 5:26
professional dan!sh 18-Jul-09 5:26 
GeneralRe: Display image in table Pin
nudma19-Jul-09 17:23
nudma19-Jul-09 17:23 
QuestionConnecting 2 computers over Internet Pin
Igor120118-Jul-09 3:56
Igor120118-Jul-09 3:56 
AnswerRe: Connecting 2 computers over Internet Pin
dan!sh 18-Jul-09 5:28
professional dan!sh 18-Jul-09 5:28 
GeneralRe: Connecting 2 computers over Internet Pin
Igor120118-Jul-09 5:44
Igor120118-Jul-09 5:44 
GeneralRe: Connecting 2 computers over Internet Pin
dan!sh 18-Jul-09 5:53
professional dan!sh 18-Jul-09 5:53 
GeneralRe: Connecting 2 computers over Internet Pin
Igor120118-Jul-09 6:03
Igor120118-Jul-09 6:03 
QuestionRe: Connecting 2 computers over Internet Pin
harold aptroot18-Jul-09 6:17
harold aptroot18-Jul-09 6:17 
AnswerRe: Connecting 2 computers over Internet Pin
Igor120118-Jul-09 6:38
Igor120118-Jul-09 6:38 
GeneralRe: Connecting 2 computers over Internet Pin
harold aptroot18-Jul-09 6:47
harold aptroot18-Jul-09 6:47 
GeneralRe: Connecting 2 computers over Internet Pin
Igor120118-Jul-09 7:17
Igor120118-Jul-09 7:17 
GeneralRe: Connecting 2 computers over Internet Pin
harold aptroot18-Jul-09 7:25
harold aptroot18-Jul-09 7:25 
GeneralRe: Connecting 2 computers over Internet Pin
Igor120118-Jul-09 7:32
Igor120118-Jul-09 7:32 
GeneralRe: Connecting 2 computers over Internet Pin
harold aptroot18-Jul-09 7:38
harold aptroot18-Jul-09 7:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.