English 中文(简体)
无法在想要的目录中创建临时文件
原标题:Not able to create temp file in the desired directory

我需要在 MAC 的指定文件夹中创建一个临时文件。 但是, 我能够在正确的位置创建文件夹, 但无法在内部创建文件 。 我收到一个错误, 显示它没有权限创建文件, 尽管我创建文件夹时已经通过 777 作为文件权限 。 请在下面找到我的代码 。 我想提及这个问题只在 MAC 上存在 。 在窗口上, 它会按预期执行 。 请告诉我问题是什么 。

    wxString curDir = SeeWorkingDir() + wxT("Temp\"); //Gets the working directory

    if(!wxFileName::DirExists(curDir)) //Checks if directory exists
    wxFileName::Mkdir( curDir, 0777, wxPATH_MKDIR_FULL ); // creates the directory

    wxString jobcopy = wxFileName::CreateTempFileName(curDir); // should create temp file
最佳回答

我完全不知道您的“ SeworkDir () () )” 函数正在返回什么, 但如果它返回了应用程序目录, 那么您就不应该在那里写任何内容 。

为什么不将“SeworkDir () () )”替换为Macintosh上某处的路径,即ruly 是可以写成的,比如“/tmp/ 目录”?

问题回答

您没有解释您的函数 SeeWorkDir () 的功能 。

也许你应该使用 wxFileName:: GetTempDir 来指定您存储文件的目录。 这应该是独立的平台 。

或者,在您的调用 wxFile Name:: CreateTempFileName( curDir)中, 您可以指定 fileTemp 参数来直接打开文件 。

See the documentation: wxWidgets 2.8.12 - wxFileName





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签