Delete a File
-
I've created a Dialog based application that records audio(using DirectX of course) and changes the header of the audio file so that I get a file that is not playable by a regular player. Now,within my application itself,when I want to playback the said file,I decode the file to a "temp" with no extension and play it back. However I cant seem to delete the file either when I exit the application or when it finishes playing. I believe my application isnt letting go of the file when it finishes playing it despite the fact that I set all the DirectX interfaces to NULL(I tried to delete the file manually after it finished playing and got an "Access Denied" error) Any suggestions anybody?? Thank You
-
I've created a Dialog based application that records audio(using DirectX of course) and changes the header of the audio file so that I get a file that is not playable by a regular player. Now,within my application itself,when I want to playback the said file,I decode the file to a "temp" with no extension and play it back. However I cant seem to delete the file either when I exit the application or when it finishes playing. I believe my application isnt letting go of the file when it finishes playing it despite the fact that I set all the DirectX interfaces to NULL(I tried to delete the file manually after it finished playing and got an "Access Denied" error) Any suggestions anybody?? Thank You
-
-
I'd try that IF i was exiting the application. But if I'm fooling around by recording and then repeatedly playing back,I'd like to be able to delete the file each time it finishes playing. Thanks for your suggestion though.Really appreciate it:)
-
You are creating a temp file right ? Close the file handle of the temp file then try DeleteFile(..) it will work Rinu Raj Rinu Raj
-
Umm, I tried that too but it doesnt work. What I am doing is using pGraph->RenderFile(abc,NULL);
-
HRESULT res; IMediaControl *pMediaControl; IMediaEventEx *pEvent; if(pGraph==NULL) { CMainDlg *parent=(CMainDlg *)AfxGetApp()->GetMainWnd(); //CoInitialize(NULL); HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph); if(hr==S_OK) { pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl); pGraph->QueryInterface(IID_IMediaEventEx, (void **)&pEvent); // pEvent->SetNotifyWindow ((OAHWND)hwnd,WM_PLAYER_ENDOFMEDIA,NULL); USES_CONVERSION; //temp=parent->m_strAppPath+"\\home\\"+parent->m_strUserName+"\\videofiles\\"+GetFileName(""); if(DecodeMediaHeaderWithCopy(fileName,"temp")) { res=pGraph->RenderFile(A2W("temp"), NULL); pGraph->QueryInterface(IID_IMediaSeeking,(void **)&g_pSeek); } else res=pGraph->RenderFile(A2W(fileName), NULL); //res=pGraph->RenderFile(A2W(fileName),NULL); if(res!=S_OK) { pMediaControl->Release (); pEvent->Release(); return FALSE; } pMediaControl->Run (); pMediaControl->Release (); pEvent->Release(); if(FileExists("C:\\Executable\\dxh263\\temp")) { CFile m_File; if(!m_File.Open("C:\\Executable\\dxh263\\temp",CFile::modeRead,NULL)) AfxMessageBox("notexs"); //m_File.SeekToEnd(); m_File.Close(); } } else return FALSE; } return TRUE; } void CMPlayer::StopPlay () { IMediaControl *pMediaControl; IMediaEventEx *pEvent; if(pGraph==NULL) return; else { pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl); pMediaControl->Stop (); pMediaControl->Release (); pGraph->QueryInterface(IID_IMediaEventEx, (void **)&pEvent); pEvent->SetNotifyWindow ((OAHWND)NULL,WM_PLAYER_ENDOFMEDIA,NULL); pEvent->Release (); pGraph->Abort(); pGraph->Release (); pGraph=NULL; pMediaControl=NULL; pEvent=NULL; } ::DeleteFile("C:\\Executable\\dxh263\\temp"); }
-
I've created a Dialog based application that records audio(using DirectX of course) and changes the header of the audio file so that I get a file that is not playable by a regular player. Now,within my application itself,when I want to playback the said file,I decode the file to a "temp" with no extension and play it back. However I cant seem to delete the file either when I exit the application or when it finishes playing. I believe my application isnt letting go of the file when it finishes playing it despite the fact that I set all the DirectX interfaces to NULL(I tried to delete the file manually after it finished playing and got an "Access Denied" error) Any suggestions anybody?? Thank You
I think the file you have opened didnot get closed so First close the file using CloseHandle or fclose.