<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QStandardPath::writeableLocation() Permission denied?]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">In one of my applications I need to open files that are stored as blobs in a database. Therefore I save them in the path I get from <code>QStandardPaths::writableLocation(QStandardPaths::TempLocation)</code>.<br />
If I read the doc of <code>QStandardPaths::writableLocation(StandardLocation type)</code> correctly, this returns me a QString with the path of writable the StandardLocation or empty string.</p>
<p dir="auto">But when I try to write a file to this location I get a "Permission Denied" Error on some Windows machines. even though I can create a file there when I open the location with the file browser and do right click -&gt; new file<br />
(On other windows and linux machines there is no problem to write the file into the TempLocation and open it with QDesktopServices)</p>
<pre><code>        q.prepare("select * from attachments where ID=:id");
        q.bindValue(":id",attid);
        q.exec();
        q.first(); //the query is always valid and returns exact 1 row
        QByteArray fc;
        QString fn;
        
            fc = q.value("content").toByteArray();
            fn = q.value("name").toString();

        
        QFile f;

        f.setFileName(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/"+fn);
       
        qDebug() &lt;&lt; f.errorString();
        if(f.open(QFile::WriteOnly)) {
            f.write(fc);
            qDebug() &lt;&lt; f.errorString();
            f.close();

            bool localOpenUrl = QDesktopServices::openUrl(QUrl::fromLocalFile(f.fileName()));
            if(!localOpenUrl)
                QMessageBox::warning(this,"Error","Failed to open attachment " + fn + "\n" + f.errorString());
        }
        else {
            QMessageBox::warning(this,"Error","Failed to open " + f.fileName() + "\n" + f.errorString());
        }
</code></pre>
<p dir="auto">Any ideas or hints what could went wrong (or what I did wrong here) here? (Or any other ways how to open a binary blob from database with the per default program?)</p>
]]></description><link>https://forum.qt.io/topic/66319/qstandardpath-writeablelocation-permission-denied</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 17:47:21 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/66319.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 22 Apr 2016 12:47:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QStandardPath::writeableLocation() Permission denied? on Fri, 22 Apr 2016 14:03:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a></p>
<p dir="auto">The QMessageBox shows the same temp. location as i can see when i run <code>set</code> in the commandline. Its the default TempLocation used by Windows ("C:/Users/&lt;USER&gt;/AppData/Local/Temp").<br />
And this piece of code always fails to write to this location on this PC.</p>
<p dir="auto">I will check for antivirus issues next time when i have access to this PC.</p>
]]></description><link>https://forum.qt.io/post/323690</link><guid isPermaLink="true">https://forum.qt.io/post/323690</guid><dc:creator><![CDATA[the_]]></dc:creator><pubDate>Fri, 22 Apr 2016 14:03:52 GMT</pubDate></item><item><title><![CDATA[Reply to QStandardPath::writeableLocation() Permission denied? on Fri, 22 Apr 2016 13:11:31 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
Just a thought, some anti virus (like avast) sometimes block such files<br />
if it seem suspicious to them.<br />
On the pc that fails, will it fail all the time?</p>
<p dir="auto">Also, does it return same path on those pc?<br />
I mean, is the  Temp location the same across working/not working?</p>
]]></description><link>https://forum.qt.io/post/323688</link><guid isPermaLink="true">https://forum.qt.io/post/323688</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Fri, 22 Apr 2016 13:11:31 GMT</pubDate></item></channel></rss>