open abc.txt: The system cannot find the file specified
使用io/ioutil包读取文件时报错:open abc.txt: The system cannot find the file specified
原因是:ioutil.ReadFile()这个方法需要传入决绝路径的文件名
代码:
const filename = "E:\\GoWorks\\Golang\\src\\if\\abc.txt"
//const filename = "abc.txt" //这样写会报错
//contents, err := ioutil.ReadFile(filename) //读取文件
//if err != nil {
// fmt.Println("err=",err)
//} else {
// fmt.Printf("%s\n", contents)
//} //上面的写法可以改为:
if contents, err := ioutil.ReadFile(filename); err != nil {
fmt.Println("err=", err)
} else {
fmt.Printf("%s\n", contents)
} //注意:if的条件里可以赋值
//if的条件里赋值的变量作用域就在这个if语句里
open abc.txt: The system cannot find the file specified的更多相关文章
- System.IO中的File、FileInfo、Directory与DirectoryInfo类(实例讲解)
一.建立的文件夹(对这些文件进行以上四个类的操作): 父目录: 父目录的子目录以及父目录下的文件: 子目录下的文件: 二.效果图 三.代码实现 using System; using System.I ...
- SD卡读写之FileNotFoundException: /storage/emulated/0object.txt: open failed: ENOENT (No such file or dir
读写sd卡中的文件依照例如以下步骤:1调用Environment的getExternalStorageState()方法推断手机上是否插入了sd卡.而且应用程序具有读写SD卡的能力 //假设手机已经插 ...
- The system cannot find the file specified
在家工作,程序在家里的电脑运行时,出现一个异常,还是第一见到: Server Error in '/' Application. The system cannot find the file spe ...
- ERROR: “System.Web.Mvc.Controller.File(string, string, string)”是一个“方法”
ERROR: “System.Web.Mvc.Controller.File(string, string, string)”是一个“方法”,这在给定的上下文中无效 这是一个与Controller.F ...
- Unable to chmod /system/build.prop.: Read-only file system
Unable to chmod /system/build.prop.: Read-only file system 只读文件系统 所以需要更改 使用下面的命令 mount -o remount,rw ...
- Docker 报错 error during connect: Get pipe/docker_engine: The system cannot find the file specified. - 摘要: 本文讲的是Docker 报错 error during connect: Get pipe/dock
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.37/version: open //./pipe/docker_ ...
- Fixed: The Windows Process Activation Service service terminated with the following error: The system cannot find the file specified
I'm not yet clear what I did, but I'm blogging it so it can be found if someone else has this issue. ...
- Nginx错误:nginx: [error] OpenEvent("Global\ngx_reload_6252") failed (2: The system cannot find the file specified)
执行nginx -s reload命令: nginx: [error] OpenEvent("Global\ngx_reload_6252") failed (2: The sys ...
- CMake error:System Error:No such file or directory CMake error:Could not open file for write in copy operation xxxx.ros_Config.cmake.tmp.
微型电脑或嵌入式与电脑还是有点不同的,在微型电脑上ros indigo 版本下利用catkin编译如果你遇到如下错误: CMake error:System Error:No such file or ...
随机推荐
- PyCharm编写的代码生成可执行文件操作步骤
1.打开Pycharm.2.打开Terminal(快捷键Alt + F12) 3.安装pyinstaller工具输入:pip install pyinstaller4.生成本项目可执行文件Termin ...
- Python面向对象 | 双下方法
定义:双下方法是特殊方法,他是解释器提供的.由双下划线+方法名+双下划线 .它具有特殊意义的方法,双下方法主要是python源码程序员使用的,我们在开发中尽量不要使用双下方法,但是深入研究双下方法,更 ...
- [RN] React Native 让 Flatlist 支持 选中多个值,并获取所选择的值
React Native 让 Flatlist 支持 选中多个值,并获取所选择的值 实现效果如下: 实现代码: import React, {Component} from 'react'; im ...
- TCGA简易下载工具 SangerBox
下载地址:http://sangerbox.com/ https://shengxin.ren/article/208 Understanding TCGA mRNA Level3 analysis ...
- 运维(SA)修仙 之路
运维(SA)修仙 之路: 大纲: 系统 ,网络 ,数据库,开发 系统 :linux(cent OS && ubuntu) 网络 :路由,防火墙,安全 数据库:mysql, mong ...
- Windows Server实例防火墙策略的配置方法
概述 本文介绍在Windows Server实例中,如何配置防火墙策略的方法. 详细描述 配置Windows Server版本的防火墙功能方法,参考如下步骤. 提示:此处以Windows Server ...
- 关于 Object.defineProperty()
通常,定义或者修改一个JS对象,有以下方式: // 1. 字面量 let obj = { name: 'cedric', age: 18 } // 2. new Object() let obj = ...
- sbt 安装
此次安装实在windows 下进行的 1.官网下载sbt 2.安装并配置环境变量 path 中添加: 3.更改sbt配置文件 1)修改C:\notos\software\sbt\conf\sbtco ...
- kali渗透
局域网-断网&劫持(kali) 1.查看局域网中的主机 fping –asg 192.168.1.0/24 2.断网 arpspoof -i wlan0 -t 192.168.100 19 ...
- nginx mysqlnd驱动引擎提升mysql性能
nginx mysqlnd驱动引擎提升mysql性能 前期要安装 mysql mysqli pdo_mysql libiconv 1 先去PHP官网下个 php-5.6.29.tar.gz wget ...