setcurrentdirectory(MFC打开和另存为问题)

本文目录
MFC打开和另存为问题
GetCurrentDirectory获取的是当前路径,并不是程序文件本身所在的路径,应用程序的当前路径是可以通过SetCurrentDirectory来改变的,当你调用CFileDialog打开文件以后,这个类就会调用SetCurrentDirectory来修改当前路径,所以你在保存时使用GetCurrentDirectory获取到的肯定是上次打开文件的那个路径,要想不改变当前路径,可以参考楼上兄弟的做法,但不推荐这样做,因为你下次打开文件的时候可能还是希望在上次打开的地方来打开,这本身是一种比较人性化的功能
如果你想获取程序本身所在的路径,可用API函数GetModuleFileName来获取,这个函数获取到的就是应用程序所在的路径,无论你是否确定当前路径是否会被改变,都建议不要用GetCurrentDirectory来获取应用程序的路径,因为不可预知会改变当前路径的因素太多了
要注意区分当前路径和应用程序所在路径,例如,你给程序创建一个快捷方式,快捷方式中的起始位置那一项设置的就是当前路径,与你目标程序的路径可以不一样;同样,在VC编译器里指定的工作路径也是当前路径,这个路径同样可以与你在命令里面设置的路径不一样,都是可以修改的
请教关于FtpSetCurrentDirectory的用法
我猜你应该使用一个JFileChooser对象的酒吧,里面有一个叫changeToParentDirectory()方法方法,该方法将被调整到当前目录,比如C盘或D盘的根目录,还有另一种方法叫做setCurrentDirectory(文件中的文件)的方法,这种方法可以直接指定当前目
eclipse一次性写出所有的set
以下是Java中Eclipse中的所有set方法:
1. setActionCommand(String command)
2. setAlignmentX(float alignmentX)
3. setAlignmentY(float alignmentY)
4. setAlwaysOnTop(boolean alwaysOnTop)
5. setBackground(Color bg)
6. setBackgroundAt(int index, Color background)
7. setBounds(int x, int y, int width, int height)
8. setBorder(Border border)
9. setBorderPainted(boolean b)
10. setBounds(Rectangle r)
11. setCancelButtonText(String cancelText)
12. setClickable(boolean clickable)
13. setColumns(int columns)
14. setContentPane(Container contentPane)
15. setCurrentDirectory(File dir)
16. setCursor(Cursor cursor)
17. setDebugGraphicsOptions(int debugOptions)
18. setDefaultButton(JButton defaultButton)
19. setDefaultCloseOperation(int operation)
20. setDefaultLightWeightPopupEnabled(boolean enabled)
21. setDialogTitle(String title)
22. setDirectoryOnly(boolean directoryOnly)
23. setDisabledIcon(Icon disabledIcon)
24. setDisabledSelectedIcon(Icon disabledSelectedIcon)
25. setDividerLocation(int location)
26. setDocument(Document doc)
27. setDoubleBuffered(boolean aFlag)
28. setDragEnabled(boolean b)
29. setEnabled(boolean enabled)
30. setExtendedState(int state)
31. setFileFilter(FileFilter filter)
32. setFocusable(boolean focusable)
33. setFocusCycleRoot(boolean focusCycleRoot)
34. setFocusOwner(Component focusOwner)
35. setFont(Font font)
36. setForeground(Color fg)
37. setForegroundAt(int index, Color foreground)
38. setIcon(Icon icon)
39. setIconAt(int index, Icon icon)
40. setIgnoreRepaint(boolean ignoreRepaint)
41. setIndex(int index)
42. setInputVerifier(InputVerifier inputVerifier)
43. setInsets(Insets insets)
44. setLabelFor(Component labelFor)
45. setLayout(LayoutManager layout)
46. setLightWeightPopupEnabled(boolean aFlag)
47. setLocale(Locale locale)
48. setLookAndFeel(String className)
49. setMaximumSize(Dimension maximumSize)
50. setMinimumSize(Dimension minimumSize)
51. setModel(BoundedRangeModel newModel)
52. setMnemonic(int mnemonic)
53. setModal(boolean modal)
54. setName(String name)
55. setOpaque(boolean isOpaque)
56. setPreferredSize(Dimension preferredSize)
57. setPrompt(String prompt)
58. setProperty(String propertyName, Object value)
59. setResizable(boolean resizable)
60. setSelected(boolean selected)
61. setSelectedIndex(int index)
62. setSelectedTextColor(Color color)
63. setSelectedValue(Object anObject, boolean shouldScroll)
64. setSelectionColor(Color selectionColor)
65. setSelectionEnd(int selectionEnd)
66. setSelectionModel(ListSelectionModel newModel)
67. setSelectionStart(int selectionStart)
68. setSplitterPosition(int position)
69. setStartOffset(int offset)
70. setState(Frame.State state)
71. setStepSize(double d)
72. setSubElements(ArrayList《Element》 subElements)
73. setTabLayoutPolicy(int policy)
74. setPreferredSize(Dimension preferredSize)
75. setToolTipText(String text)
76. setTransferHandler(TransferHandler newHandler)
77. setUI(ComponentUI newUI)
78. setValue(Object aValue, boolean isSelected)
79. setVisible(boolean b)
80. setViewportView(Component view)
81. setWantsInput(boolean wantsInput)
82. setWrapStyleWord(boolean wrap)
83. setXORMode(boolean state)
84. setYear(int year)
85. setZoom(int zoom)
86. setZOrder(Component comp, int index)
希望可以帮到您的工作。
怎么用cftpconnection类编写向ftp server上传文件
为了与FTP Internet服务器通讯,必须先创建一个CInternetSession实例,然后创建CFtpConnection对象。创建CFtpConnection对象不采用直接方式,而是调用CInternetSession::GetFtpConnertion来创建并返回一个指向它的指针。
CFtpConnection类的成员
构造函数 CFtpConnection 构造一个CFtpConnection对象
操作 SetCurrentDirectory 设置当前FTP目录
GetCurrentDirectory 获取此次连接的当前目录
GetCurrentDirectoryAsURL 获取作为URL的此次连接的当前目录
RemoveDirectory 从服务器移去指定目录
CreateDirectory 在服务器上构造一个目录
Rename 将服务器上的文件改名
Remove 从服务器上移去一个文件
PutFile 将一个文件放到服务器上
GetFile 从连接的服务器上获取一个文件
OpenFile 在连接的服务器上打开一个文件
Close 关闭与服务器的连接
实例一:上传文件
CString strAppName = AfxGetAppName();
CInternetSession* pSession = new CInternetSession(strAppName);
CFtpConnection* pConn = pSession-》GetFtpConnection("
10.46.1.232","Anonymous","",21);
pConn-》SetCurrentDirectory("test");
CString strLocfile,strRemotefile;
strLocfile="C:\\cmd.txt";
strRemotefile="cmd.txt";
pConn-》PutFile(strLocfile,strRemotefile,FTP_TRANSFER_TYPE_ASCII);
pConn-》Close();
return 0;
实例二:Ftp的打开文件操作函数:OpenFile

更多文章:
随机数公式wps(求wps 随机函数公式,从+0.005到-0.015,不能出现0)
2026年8月9日 03:15
html表格的基本语法结构(在HTML表格中align表示什么)
2025年7月20日 14:15
java开发系统流程(公司里面开发一个java项目的流程是什么)
2025年12月4日 15:30
replace belt 兄弟打印机(兄弟打印机出现replace toner cartridge是什么意思)
2025年9月26日 17:30
爱迪尔门锁系统连接数据库失败(爱迪尔 a90安装建立连接远程数据失败是怎么回事)
2026年6月1日 23:45
正则表达式匹配换行符和空格(为什么这个正则表达式不能匹配空格和换行)
2026年4月22日 13:30
unionid获取openid(怎么获取微信的unionid)
2025年5月27日 19:00
emersonev1000变频器说明书(变频器艾默生ev1000的程序,说明书关于寄存器地址的描述有几点疑惑求助)
2025年12月23日 07:15
sql server的azure扩展(如何在Azure上创建一个mssql的数据库,然后使用本机的sql management链接)
2026年6月27日 21:45
pg和mysql的区别(MySQL、PG属于分布式数据库吗怎么区分数据库是否为分布式)
2025年9月23日 06:45













