Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. mciSendString cannot save wave file

mciSendString cannot save wave file

Scheduled Pinned Locked Moved C#
helpvisual-studiosysadminquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Steve1_rm
    wrote on last edited by
    #1

    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.Le
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups