Remove File with UIDocumentPickerViewController - delete-file

i want to delete a pdf file (for example a pdf file
that are present on my iPhone) with the UIDocumentPickerViewController controller. In the info.plist I already support iTunes file sharing and support opening documents...
I want to delete the pdf file in the didPickDocumentsAt urls: method. But It doesn't work. Copy the pdf file into the app bundle is successfully but I can't delete the file from the device.
File should move from the device into my app bundle and delete it in the
on my iPhone storage.
I hope you can enlighten me. Thank you.

Set your document picker to open mode instead of import mode and copy the file manually wherever you want before deleting it. This may be very unexpected by the user though so warn them ahead of time the file is going to be deleted.

Related

I have a GUI for my program that saves a config file, how can I double click on this config file to load the GUI directly with the config data?

So I have this program written in C++, and I created a GUI application (using Qt5) for it that runs on Windows.
On the GUI, you can enter some data (for e.g. Name, Age, Date,...). With this data some processing can be done.
The GUI is able to serialize and save the data I entered (Name, Age, Date..) into a binary or text file (or basically anything). The GUI can also load this config file with this data.
However, what I want is that wherever I save this config file, I want to be able to double-click on this config file and it should link to the GUI application to run, and of course display the data that was saved in the config file.
So my question is what tools/considerations do I need to get this feature (at least on Windows)?
There is probably more than one way to implement this feature. Here is what I would do:
Make a unique file type for the config file (a dot extension like .myappconf or something like that should do it)
Create a file association for your application with that file type. This is typically done in the installer or in the .desktop file when you are on Linux.
Now with this association the action of double clicking the file will trigger your Operating System to run a new copy of your app and present it with the config file (via a command line argument).
The application should check on startup if there is already a copy of it running. If so, it should send a notification about the config file to the old copy and then self-terminate.
Note: If you are okay with the double click action starting up a new copy instead of loading the file into the old one (if any), you can skip the last step.

toad locks folders from editing

Say I have test.sql opened in Toad and I close it. It seems Toad still 'looks' at the location of this file. Namely, after closing it, I can edit the file itself, but not the folder it is in, as attempts to do so result in the error message "The action can't be completed because the folder or a file in it is open in another program".
Closing the file doesn't help, ending the connection in which I opened it doesn't help. But closing Toad does the trick, so I'm guessing Toad still has the location of the file memorized.
My issue is that I do not want to close Toad to edit the name of the folder. Does anyone know if this is possible? Is there for example an overview of which locations are in use/looked at by Toad?
You can't delete the folder if it is Toad's current directory. As a workaround you can browse to a new folder location in a Toad open dialog. You may need to actually open a file from that new location. As I Google it there's a property of the open dialog used to not change the current directory. It's too late to change for the release underway (12.10), but I'll log a bug report to revisit this for the next release of Toad.
I had the same issue in 12.0.0.61 after exporting a data set. I tried opening a random file from another location, but that did not work in my case.
One workaround that I did find to be successful is to open the FTP utility and manually change the current folder. When opening the FTP utility in TOAD, the "local system" location will default to the current folder. In my case, I just went up a level and that releases the hold on the folder I'm trying to modify.

How to attach MS word document in Qt GUI application?

I wrote a Qt widget application. In the file menu I want to insert an MS word document as a user manual. Is there any way to do it? I checked Qt help and various blogs but none of them gave me a clear solution.
If it is only manual then it is not necessary to embed MS Word inside your app. Maybe try to open needed document with Word installed in computer. Try this code:
QDesktopServices::openUrl(QUrl("file:///G:/tst.docx"));
Just set needed path. As doc said:
If the URL is a reference to a local file (i.e., the URL scheme is
"file") then it will be opened with a suitable application instead of
a Web browser.
If you want to embed it in your application executable, just insert your .docx file as a resource file. To open the docx file from resources, you should first copy it to some location for example in the application directory path :
QFile HelpFile("qrc:/myFile.docx");;
HelpFile.copy(qApp->applicationDirPath().append("/myFile.docx"));
Next you can open it by :
QDesktopServices::openUrl(QUrl::fromLocalFile(qApp->applicationDirPath().append("/myFile.docx")));

How can I replace an exising file into the assets folder with a refresh stuff?

I'm develepping a BB10 mobile application using the momentics IDE.
I'm trying to save somes images coming from server into the "assets/images" folder using the Qt QFile object (you can see the code below) :
m_file = new QFile(argSavingFilePath);
if (m_file->exists()) {
m_file->remove();
}
m_file->open(QIODevice::WriteOnly);
m_file->write(argDataLoaded);
m_file->close();
m_file->~QFile();
It seems that is working but even if I exit out of the screen in question with the back button and then return it still doesn't show the latest image. It only works when I exit the app completely and launch a new instance.
According to this forum [link], they said :
"What's happening is that when you first load the image it gets read from the file system and then cached in memory. The app never goes back to re-read the image from the file. You would have to initiate that yourself."
How should I initiate the cashed memory myself ? is this the only solution ?
Whether the data is cached in memory or not is immaterial. The asset directory, in fact everything below and including the app directory is protected and immutable.
If you want to store data from a server the place to put it would be in data if you want it to persist, or tmp if not. Data in the tmp director is subject to removal by the OS when storage is needed for other things.
See: https://developer.blackberry.com/native/documentation/cascades/device_platform/data_access/file_system.html

How can I read the source URL of a file downloaded with FireFox from an external application?

I have an C++ app I built which is registered as the default handler for a file with a specific extension. So when I download one of these files with Firefox from a website, it downloads it to a temp directory and then shell executes my app while passing the full path to the downloaded file on the command line.
What is the best way to figure out from the external app what the original download url of the file was, given only it's path on disk? Can I use XPCOM API calls to inspect the FireFox download manager database?
I've figured out that this data get's stored in the "%APPData%\Mozilla\Firefox\($profile)\downloads.sqlite" file which is a SqlLite db file, but I really rather not try to open this file directly as FireFox has an open write handle to the file while running.
After perusing the Mozilla developer center for a while, I ran accross the nsIDownloadManager service, which seems to be just the thing. But I can't seem to get access to it from XPCOM in a separate process?
Here's the code I am using:
nsresult rv;
//init XPCOM
nsCOMPtr<nsIServiceManager> servMgr;
rv = NS_InitXPCOM2(getter_AddRefs(servMgr), nsnull, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
//Get a download manager instance
nsCOMPtr<nsIDownloadManager> downloadMgr;
rv = servMgr->GetServiceByContractID(NS_DOWNLOADMANAGER_CONTRACTID,
nsIDownloadManager::GetIID(), getter_AddRefs(downloadMgr));
NS_ENSURE_SUCCESS(rv, rv);
When I run this, the GetServiceByContractID() call returns 0x8007000e, which is defined in nsError.h as NS_ERROR_OUT_OF_MEMORY. (which I find very weird).
Any ideas here? Am I barking up the right tree?
No, you can't access Firefox's XPCOM objects from an external process, and you also shouldn't open the sqlite database while Firefox has it open. I don't know that there's any straightforward way to do what you want without writing a Firefox extension that has access to the Firefox internals.
I'm a little hazy on the details right now, but, assuming that your download is served with a custom MIME type, it's possible to register a handler for that type; your handler can then cancel the download and pass the URL to your application.