I think that you can exclude it:
CString example = _T("Solid.PDF.Tools.10.1.12248.5132.rar?1629176293");
int i = example.FindOneOf( _T("?#") );
CString filename = i >= 0 ? example.Left( i ) : example;
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi
I using following code to get a file information from url, but GetFileName() method not return pure filename! it just returns part of url including trailing numbers!
CInternetSession sess;
CHttpFile* pfile = (CHttpFile*)sess.OpenURL(_T("https://dl2.soft98.ir/soft/s/Solid.PDF.Tools.10.1.12248.5132.rar?1629176293"), 1, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_RELOAD);
if (pfile)
{
TRACE0("ok\n");
TRACE1("Filename: %s\n", pfile->GetFileName()); // output is: Solid.PDF.Tools.10.1.12248.5132.rar?1629176293
DWORD dw;
pfile->QueryInfo(HTTP_QUERY_CONTENT_LENGTH, dw);
TRACE1("File lenght: %u\n", dw);
pfile->Close();
delete pfile;
}
sess.Close();
I think that you can exclude it:
CString example = _T("Solid.PDF.Tools.10.1.12248.5132.rar?1629176293");
int i = example.FindOneOf( _T("?#") );
CString filename = i >= 0 ? example.Left( i ) : example;
According to your description, I wonder if you want to get the filename from the URL and the filename is not contained in the URL? If so, you couldn't get internet filename via GetFileName() method
As far as I'm concerned you could inspect the Content-Disposition response header using an HTTP request to get the filename.