Cocoa Application on remote files? - objective-c

I have created a small application that selects the files and renames spaces into underscores and few other symbols. It works fine when I tried with the files on my desktop but it fails to execute when i try with files on my remote server. The problem is it doesn't show any signs of error. In my application, once the files are renamed, I will get a notification on my app stating the number of files renamed. It does show that the file is renamed but I couldn't find the renamed files. Any suggestion as to why it happens or any fixes for this please.
I have created the application and exported as a Mac Executable Application.

Solved: NSFileManager recognises file paths in different formats so we need to change according to the default path format with which Mac recognises and update files. I changed accordingly and it works. Thanks for you help.

Related

invalid byte 2 of 2-byte UTF-8 sequence in resource files after importing the worklight template

I'm trying to create a Worklight project in Worklight Studio 6.1 from a template. It's a straight forward process as described here: http://pic.dhe.ibm.com/infocenter/wrklight/v6r1m0/index.jsp?topic=%2Fcom.ibm.worklight.dev.doc%2Fstudio_ext_assets%2Fc_wl_project_templates.html
However I'm getting "invalid byte 2 of 2-byte UTF-8 sequence" exceptions on some of the settings.xml files inside the android environment's native resources when trying to compile newly created project.
The files are in utf-8 inside the template and I have utf-8 set up for my workspace file encoding ( Preferences->General->Workspace ).
But after extracting stuff from the template ( which is really a zip bundle ) looks like it changes encoding somehow.
Problem goes away when you try to re-save .xml file (for example - open it, add a char somewhere, delete it and save). But this is not an option since we are going to deliver the template to a customer and this will affect the 'user experience'.
Also, the same exact template works fine on linux platform. I saw this issue on windows.
Has anybody experienced this before and could share any info on how to fix it?
Thank you.
Make sure that under Preferences->General->Workspace in Eclipse, the default text file encoding is set to UTF-8 and not US-ASCII (usually by default it is set to ASCII). This should take care of the encoding problems.

Qt icons from resource file do not display

I made a user interface using Qt Designer qith Qt 5.0.1, and I used icons from a resource file. After compiling, the executable runs perfectly fine, and the icons are displayed as expected. However, when I run the programme on a different computer, they mysteriously disappear, and I am not able to get them back.
What can be the reason for this? I thought that the resources where hard-coded in the executable after compilation, but that may be wrong. In any case, I find it very peculiar that wherever I move the executable, it displays the icons on my own computer, but not on another one's.
I think you're missing some plugins. If you're using Windows and your icons are .ico type files, you need to copy the qico.dll file from the imageformats folder located somewhere in your Qt folder (something like C:\Qt\Qt5.0.1\5.0.1\mingw47_32\plugins\imageformats) to a subdir called imageformats that you create inside the directory that contains your deployed .exe file.

Windows Phone 8 don't added pdf files at build

Comparing the source and the console log I saw that all pdf files aren't adding. For this reason (obviously) the app crash when I call some pdf file. Another files (.png, .xml, .html, ...) don't have any problems.
What is the reason? I need add to another location?
thx
You should try to set build action for your *.pdf files to "Content". It works in my project.

Working Directory in Objective-C and Xcode: debug mode vs. executable

I am writing a program in Objective-C using Xcode. My program creates a file as follows:
[#"" writeToFile:fileName atomically:YES encoding:NSUTF8StringEncoding error:NULL];
I would like the file to be created in the same directory as the executable. When I run the program from Xcode, the file is created in the debug directory as expected.
However, when I run the .app file, the file is created in the root directory. How can I get the program to create a file in the directory where the .app file is located.
Thanks a lot.
EDIT: This is a MacOS application
EDIT2: Well, it seems that I shouldn't be writing to the .app directory. Thanks bbum and Paul R. What is the proper way to do it? To be more concrete, here's what I am doing: each time the user clicks a button in the application, a piece of hardware connected to a serial port will send a bunch data which will be written to a new file. This can happen any number of times while the application is running, so numerous files may be created. I would like them all created in the same folder.
You must never make any assumptions about the initial working directory for your application, as this will depend on what method was used to launch it (e.g. Finder, Terminal (via open), Xcode, gdb, third party utility, etc). You should use an appropriate API to find a suitable directory to store temporary files or user-specific files or whatever it is you need to do. This should never be within the app's bundle and never at a path that is relative to the initial working directory.
You do not want the file to be created inside the .app wrapper. That is never the right answer; your application may easily be installed somewhere where the current user does not have write access to the YourApp.app wrapper.
(For example, my main user account is non-admin and all applications are installed admin-write-only. If an app ever fails to work because it can't write to its app wrapper, the app goes in the trash.)
See this question for an outline of where files should be stored. Depends on the role of the file.

Creating a temporary file in VB on Windows 7 PC

I have a VB program that creates a temporay PDF file then opens Outlook and attaches the file. I create the file in the application path (the location that the program is running from - normally C:\Program Files\ProgamName). This works fine in XP as it appears there are no crazy permission issues. However in Windows 7, the file does not appear. There are no errors, the file does not exist in that location.
I've changed the path to the root of C:\, however this doesn't work either. I suspect it's something to do with W7 virtualisation, so the question is where can I create a file that I can then access again?
I was trying to avoid creating it on a share on a server, but it's looking like this is the only place to put it as there doesn't seem to be many places a user can write files to in Windows 7.
Surely there must be a location that users can access (without being administrators) to create files. Don't even get me started on the fun I have had with the registry in W7!!!
Thanks
Patrick
You need to create the file in the system's temp directory, which you can find by calling Path.GetTempPath().
In general, your program should only write to files in the user's Application Data (or temp) directories and only write registry keys in HKEY_CURRENT_USER. (This is true in any version of Windows)
If you follow these guidelines, you won't have any trouble in Windwos VIsta or 7.
You should never write information to places that are shared by multiple users.
Edit: While the following will work, SLaks points out it's bad practice, and the temp file won't get cleaned up.
Try %HOMEPATH% - this is the environment variable for a users documents folder, and should work no matter which version if windows you use.
In other words where you used to have:
"c:\programfiles\programname\tempFileName"
use:
"%HOMEPATH%\tempFileName"