file-io

python open() - access denied

浪子不回头ぞ 提交于 2021-02-20 19:36:55
问题 This is my first post on stackoverflow, so if somethings wrong I'm eager to learn! I'm programming a plugin for Cinema 4d with python. Everything works on Mac, but I'm having problems on Windows with what I'm about to explain. The plugin needs a path to a server, in case of rendering on a renderserver. I want the user to enter the path once, and to then store it in a .txt file. for c4d, plugins are being installed, by draging-and-droping the plugin into the plugin folder at for example: C:

python open() - access denied

我怕爱的太早我们不能终老 提交于 2021-02-20 19:36:13
问题 This is my first post on stackoverflow, so if somethings wrong I'm eager to learn! I'm programming a plugin for Cinema 4d with python. Everything works on Mac, but I'm having problems on Windows with what I'm about to explain. The plugin needs a path to a server, in case of rendering on a renderserver. I want the user to enter the path once, and to then store it in a .txt file. for c4d, plugins are being installed, by draging-and-droping the plugin into the plugin folder at for example: C:

How to Close SafeFile Handle properly

二次信任 提交于 2021-02-20 18:12:24
问题 I am working on a c# project where i communicate with an USB device. I open the connection with: [DllImport("Kernel32.dll", SetLastError = true)] static extern Microsoft.Win32.SafeHandles.SafeFileHandle CreateFile(string filename, [MarshalAs(UnmanagedType.U4)]FileAccess fileaccess, [MarshalAs(UnmanagedType.U4)]FileShare fileshare, int securityattributes, [MarshalAs(UnmanagedType.U4)]FileMode creationdisposition, int flags, IntPtr template); private Microsoft.Win32.SafeHandles.SafeFileHandle

Programmatically open a file in Visual Studio (2010)

余生长醉 提交于 2021-02-20 08:32:12
问题 I'm building a VS package, and I'm trying to send a command from the package to Visual Studio to open up a user selected file in a new tab (just like a user would do it by going to File -> Open...). I remember seeing at some point how to do this. Can anybody refresh my memory? 回答1: I believe you want one of: IVsUIShellOpenDocument.OpenStandardEditor DTE.OpenFile DTE.ItemOperations.OpenFile In the end, I think they all boil down to the same behavior. 回答2: I like to use the DTE method

Python 3: How to ignore line breaks when using input()

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-19 08:28:23
问题 while count != 5: input_text = input("Please insert a number of lines of text \n") if count != 5: print("Count is " + str(count)) For the code above, when prompted to supply input, if I paste in a text with multiple line breaks. The code will run for the number of line breaks! I just want it to run ONCE for the entire text. Can anyone help? 回答1: You can use sys.stdin.read() but it will require you to manually send the EOT character: >>> import sys >>> x = sys.stdin.read() the quick brown fox

C++: ifstream::getline problem

会有一股神秘感。 提交于 2021-02-19 05:25:53
问题 I am reading a file like this: char string[256]; std::ifstream file( "file.txt" ); // open the level file. if ( ! file ) // check if the file loaded fine. { // error } while ( file.getline( string, 256, ' ' ) ) { // handle input } Just for testing purposes, my file is just one line, with a space at the end: 12345 My code first reads the 12345 successfully. But then instead of the loop ending, it reads another string, which seems to be a return/newline. I have saved my file both in gedit and

C++: ifstream::getline problem

*爱你&永不变心* 提交于 2021-02-19 05:24:57
问题 I am reading a file like this: char string[256]; std::ifstream file( "file.txt" ); // open the level file. if ( ! file ) // check if the file loaded fine. { // error } while ( file.getline( string, 256, ' ' ) ) { // handle input } Just for testing purposes, my file is just one line, with a space at the end: 12345 My code first reads the 12345 successfully. But then instead of the loop ending, it reads another string, which seems to be a return/newline. I have saved my file both in gedit and

How to manage the transaction(which includes File IO) when an IOException is thrown from the close file method

假装没事ソ 提交于 2021-02-18 22:07:07
问题 I've recently begun using Spring's Data Source Transaction Manager. I have a problem now. My transaction includes updates to a DB table and a write operation to a file. It works fine but I have some doubts about file I/O. As you see below, I have configured openFile and closeFile methods of my bean as the init-method and the destroy-method respectively, which in turn provides those methods to be called just like a constuructor and a destructor. If the file is not closed properly, some of the

How do you serve a file without leaving the page?

这一生的挚爱 提交于 2021-02-18 20:37:15
问题 Aims I'm trying to let users download a file (myfile.zip in this case) by clicking a button on the page, without them leaving the page - ie the browser must stay on the current page, and leave them in a position where they can continue to use the page, including clicking the button again (should they wish to get a new copy of the file). I need this to work across all browsers (IE6-8, Firefox, Chrome, Opera, Safari). Background Packaged inside the zip is a selection of stuff based on their

Non-threadsafe file I/O in C/C++

余生颓废 提交于 2021-02-18 12:03:10
问题 While troubleshooting some performance problems in our apps, I found out that C's stdio.h functions (and, at least for our vendor, C++'s fstream classes) are threadsafe. As a result, every time I do something as simple as fgetc , the RTL has to acquire a lock, read a byte, and release the lock. This is not good for performance. What's the best way to get non-threadsafe file I/O in C and C++, so that I can manage locking myself and get better performance? MSVC provides _fputc_nolock, and GCC